
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
next-impl-config
Advanced tools
The package allows for convenient management of application configuration in Next.js environments.
The package allows for convenient management of application configuration in Next.js environments.
For the config, Next.js only offers environment variables - regular ones for the server, and ones with NEXT_PUBLIC prefix, which will be embedded during the build process.
And here are a few downsides:
On the other hand, next-impl-config offers support for 4 different configuration options for your applications.
Another important advantage of next-impl-config is that it supports functions (synchronous and asynchronous) and will successfully merge their result.
Using npm:
npm i next-impl-config
Using yarn:
yarn add next-impl-config
All configs are stored in the config directory. Each variant is stored independently in a subdirectory with the same name.
config
All types support the following config variants:
The lower the config variant is in the list, the higher its priority.
The config is generated at runtime (based on the environment conditions at runtime).
Recommended for API routes or in force-dynamic mode in server components.
import { serverConfig } from 'next-impl-config/server-config';
// ...
const config = await serverConfig;
The config is generated at build time (based on the environment conditions at build time).
Recommended for components that don't depend on the runtime environment.
import { buildConfig } from 'next-impl-config/build-config';
// ...
const config = buildConfig;
During the build process, configs are generated for each possible environment (based on the environment conditions at build time). Then, at runtime, the appropriate version is selected.
Recommended for middleware.
import { postbuildConfig } from 'next-impl-config/postbuild-config';
// ...
const config = postbuildConfig;
An API route is created that generates the config at the time of the request (based on the environment conditions at runtime). Then, on the client side, a provider is initialized that loads the config and returns it after loading (triggering a re-render).
Recommended for components that depend on the runtime environment.
'client';
import useRuntimeConfig from 'next-impl-config/use-runtime-config';
// ...
const config = useRuntimeConfig();
if (!config) return <p>Loading...</p>
// ...
This type doesn't require any additional configuration.
Next.js config needs to be wrapped with nextImplConfig.
/// next.config.js
const nextImplConfig = require('next-impl-config/with-next-impl-config').default;
/** @type {import('next').NextConfig} */
const nextConfig = {
// ...
};
module.exports = nextImplConfig()(nextConfig);
Possible environments need to be passed to nextImplConfig.
/// next.config.js
const nextImplConfig = require('next-impl-config/with-next-impl-config').default;
/** @type {import('next').NextConfig} */
const nextConfig = {
// ...
};
module.exports = nextImplConfig({ envs: ['development', 'staging', 'production'] })(nextConfig);
First, create an API route.
/// app/api/config/route.tsx
export { runtimeConfigApi as GET } from 'next-impl-config/runtime-config-api';
Wrap the application with the Provider.
/// app/layout.tsx
import RuntimeConfigProvider from 'next-impl-config/runtime-config-provider';
export default function RootLayout() {
return (
<RuntimeConfigProvider apiPath='/api/config'>
// ...
</RuntimeConfigProvider>
);
}
The default Environment-dependent config is the config with the current NODE_ENV. If you want to use a different key, pass it to nextImplConfig
/// next.config.js
const nextImplConfig = require('next-impl-config/with-next-impl-config').default;
/** @type {import('next').NextConfig} */
const nextConfig = {
// ...
};
module.exports = nextImplConfig({ envs: ['development', 'staging', 'production'], targetEnv: process.env.MY_CUSTOM_ENV })(nextConfig);
/// next.config.js
const nextImplConfig = require('next-impl-config/with-next-impl-config').default;
/** @type {import('next').NextConfig} */
const nextConfig = {
// ...
};
module.exports = nextImplConfig({ folder: 'custom-config-folder' })(nextConfig);
When the application runs, the package will create a file with type declarations - next-impl-config.d.ts.
After this, each config variant will be typed exactly in accordance with the default config.
FAQs
The package allows for convenient management of application configuration in Next.js environments.
We found that next-impl-config demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.