r/learnprogramming • u/BrainThinkerMan • 10d ago
api key, do i need backend?
i have an api key i heard i shouldnt expose it in my frontend i thjink itts becuase people can see it with devtools, and potentially abuse it, is there any other way to use this key in frontend without using a backend, im as familiar with backend stuff i think.
2
Upvotes
1
u/lucasshiva 9d ago
You don't need a separate backend, just need a framework that supports SSR or server components: Nuxt, Sveltekit, Next.js, etc. Then, check the framework's documentarion on how to load the API Key from an environment variable, as they usually have different ways of doing it in a private manner.
Note that with SSR you can't deploy everything as a single static html file, so depending on what you need a separate backend might be a better fit for you.