Home > Mobile >  How to get the npm script arguments in reactjs
How to get the npm script arguments in reactjs

Time:05-11

How can i access these flags -

npm run start --appenv=development --build=mobile

here i want to achieve the value of appenv and build in my react code

CodePudding user response:

npm run start -- --appenv=development --build=mobile

CodePudding user response:

If you've setup a basic react app without any "framework", you'll need something extra to access these environment variables.

You can do it with Webpack: https://webpack.js.org/guides/environment-variables/

Or if you're using CRA: https://create-react-app.dev/docs/adding-custom-environment-variables/

Or if you're using NextJs: https://nextjs.org/docs/basic-features/environment-variables

  • Related