add dollar sign characters to React app env file

Viewed 1759

I need to store variable with $ sign in env but when I`m trying to use it gets omitted.

Why is that happens and how to fix it?

REACT_APP_EXAMPLE="QWE$EWQ"

my log out next:

QWE

3 Answers

You need to "skip" (escape) the dollar sign. With the variable name, it serves as a placeholder for the variable value that will added to the string later.

Skip it by using a backslash "\", like this: "QWE\$EWQ".

Just I want to add that you should always restart your save after saving ur .env file so the new changes would be taken and remember always to prefix the name the react env var with REACT_APP_ ex:

REACT_APP_PASSWORD=Mp\$2626

I had this environment variable:

REACT_APP_EXAMPLE="QWE$EWQ"

I had to switch to single quotes and use a backslash to escape $ properly:

REACT_APP_EXAMPLE='QWE\$EWQ'
Related