Storing keys without exposing them #14392
-
Hey! I'm new to Nextjs. I wanted to store some secrets but I'm a bit confused about what is the correct way of storing secrets in a Nextjs app? Does storing keys in my Can someone please suggest a good method of storing and utilising keys securely? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Do you mean the
When storing variables in the |
Beta Was this translation helpful? Give feedback.
Do you mean the
env
field ofnext.config.js
? Everything in this field can go into the JS bundle, so they are public.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 likegetStaticProps
or in the API routes. These variables aren't public yet, they can only be accessed from the client if you prefix them withNEXT_PUBLIC_
, then they become public