next-build-id-env
v0.1.1
Published
🛠️ Easily inject your Next.js build ID into your environment variables for enhanced build tracking and tracing.
Downloads
32
Maintainers
Readme
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-env
Usage
// 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