Next.js Discord

Discord Forum

Multi Line Env Variables

Answered
West African Lion posted this in #help-forum
Open in Discord
West African LionOP
How do i do multi line variables, I need a certificate public key and private key to access some payment api, i was thinking of keeping them as env variables but when i check what's read from env.local i see only the first line of the long block of text being read. How do i make it read the whole thing, i've tried single and double quotes
Answered by linesofcode
Another approach here
View full answer

11 Replies

Never tried this so i dont know, but from what i found on the internet:

Just wrap it in quotes and add a newline character (\n) before the end of each line
Another approach here
Answer
Is to encrypt your certificates or any other files
And include them in your repository
Then you only store the encryption key in a env variable
And use it to decrypt your files during runtime or build time
West African LionOP
thanks @linesofcode that sounds like a great idea, @Clown that might work but my certificates are pretty lenghty and i don't have the patience 🙂
Good luck!
Yah if you’re also using vercel
There is a 4kb limit for env variables
So often times you’ll exceed it if trying to store non trivial values