Skip to content

Storing keys without exposing them #14392

Discussion options

You must be logged in to vote

Does storing keys in my next.config.js make them untraceable from the front-end?

Do you mean the env field of next.config.js? Everything in this field can go into the JS bundle, so they are public.

If not, what really is the difference between storing keys in a simple .env file or a next.config.js file?

When storing variables in the .env file, Next.js will load them into the Node.js environment. This means you can use these variables in the data-fetching methods like getStaticProps or in the API routes. These variables aren't public yet, they can only be accessed from the client if you prefix them with NEXT_PUBLIC_, then they become public

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sachdeva-shrey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants