0.1.1 • Published 2 years ago
next-build-id-env v0.1.1
next-build-id-env
A Next.js configuration enhancer to effortlessly inject your build ID into your environment variables.
Installation
npm install next-build-id-env
# or
yarn add next-build-id-envUsage
// next.config.js
const withBuildId = require('next-build-id-env')({
name: 'NEXT_PUBLIC_BUILD_ID', // optional (default: 'NEXT_PUBLIC_BUILD_ID')
});
const nextConfig = {};
module.exports = withBuildId(nextConfig);// pages/index.js
export default function Home() {
const buildId = process.env.NEXT_PUBLIC_BUILD_ID;
return (
<div>
<h1>My Next.js App</h1>
<p>Build ID: {buildId}</p>
</div>
);
}Options
| Option | Type | Default | Description |
|---|---|---|---|
| name | string | 'NEXT_PUBLIC_BUILD_ID' | The name of the environment variable to hold the build ID. |
License
MIT