.env.development.local !!better!!
Remember: commit the shared .env.development , ignore the local .env.development.local , and always respect the load order. Do this, and you will never again have the dreaded "but it works on my machine" argument over environment variables.
// Available in the browser and server console.log(process.env.NEXT_PUBLIC_ANALYTICS_ID); // Available ONLY in server-side functions (getServerSideProps, API routes) console.log(process.env.DATABASE_URL); Use code with caution. Best Practices for Managing .env.development.local
: Indicates that this file is specific to your local machine . It overrides standard development settings and should never be shared with other team members. .env.development.local
A common industry practice is to provide an .env.example file in the repository, which lists all the required environment variables with placeholder values. This serves as documentation and a template for new developers to create their own .env.development.local file.
Create a .env.example file that contains the keys but not the values, and commit that to version control. This tells other developers what variables they need to set up. Remember: commit the shared
Now, let's focus on .env.development.local . This file is a variant of the .env file, specifically designed for development environments. The .development.local suffix indicates that this file contains environment variable settings for a local development environment.
You want to enable a new feature locally that isn't ready for production. Best Practices Best Practices for Managing
The files you should commit to your Git repository are the shared, non-secret ones: .env for base defaults, .env.development for dev defaults, and .env.production for production defaults. This setup ensures that anyone cloning the repository gets a working set of configurations without sensitive data.
Do you need help configuring a file for a multi-package monorepo? Share public link