next-build-id-env
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

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

Option Type Default Description
name string 'NEXT_PUBLIC_BUILD_ID' The name of the environment variable to hold the build ID.

License

MIT

Package Sidebar

Install

npm i next-build-id-env

Weekly Downloads

5

Version

0.1.1

License

MIT

Unpacked Size

5.27 kB

Total Files

7

Last publish

Collaborators

  • almondbongbong