Socket
Book a DemoInstallSign in
Socket

next-env-loader

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-env-loader

Load custom .env files depending on your environment in Next.js

1.0.0
latest
Source
npmnpm
Version published
Weekly downloads
4
-55.56%
Maintainers
1
Weekly downloads
 
Created
Source

next-env-loader

Load custom .env files depending on your environment in Next.js

Description

Usually our apps run in at least three different configurations. With vanilla Next.js it's only possible to load .env.development, .env.production and .env.test, which is insufficient for good amount of use-cases.

This library create an abstraction layer responsible for loading your Dotenv files required for given environment. It uses envs directory by default, but that can be easily changed through configuration object.

Usage

  • Install this package using your favourite package manager
# NPM
npm install next-env-loader

# Yarn
yarn add next-env-loader

# PNPM
pnpm add next-env-loader
  • Update your .next.config.js and pass current environment name using environment property of config object
const nextConfig = {}; // Your Next.js config
const nextEnvLoaderConfig = {
  environment: process.env.ENVIRONMENT, // Inform next-env-loader which environment is active
},

module.exports = withNextEnvLoader(nextConfig, nextEnvLoaderConfig);
  • Run your app and notice similar log entry
info  - Using environment variables from /your-app-dir/envs/.env.dev

Keywords

next.js

FAQs

Package last updated on 06 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.