What is @next/env?
The @next/env package is designed to load environment variables for Next.js projects. It allows developers to define environment variables in .env files and access them in their Next.js applications, ensuring that sensitive information is not hard-coded into the source code. This package is particularly useful for managing different configurations across various deployment environments, such as development, testing, and production.
Loading environment variables
This code snippet demonstrates how to load environment variables from the .env file in a Next.js project. It uses the `loadEnvConfig` method from the @next/env package, which reads the environment variables defined in the .env file and makes them available through `process.env`.
require('@next/env').loadEnvConfig(process.env.PWD || process.cwd())