0.1.1 • Published 7 months ago

next-build-id-env v0.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

next-build-id-env

NPM License Size

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

OptionTypeDefaultDescription
namestring'NEXT_PUBLIC_BUILD_ID'The name of the environment variable to hold the build ID.

License

MIT