All Projects → nexdrew → Next Build Id

nexdrew / Next Build Id

Licence: isc
Easily set your `next build` BUILD_ID to the latest git commit hash

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Next Build Id

next-motion
page transitions with nextjs and framer motion api
Stars: ✭ 25 (-87.68%)
Mutual labels:  nextjs, zeit
Meteor Now
Instantly deploy your Meteor apps with `meteor-now`
Stars: ✭ 339 (+67%)
Mutual labels:  cli, zeit
devdevdev
The next trendy apparel e-commerce store maybe?
Stars: ✭ 27 (-86.7%)
Mutual labels:  nextjs, zeit
Bcrypt
A Java standalone implementation of the bcrypt password hash function. Based on the Blowfish cipher it is the default password hash algorithm for OpenBSD and other systems including some Linux distributions. Includes a CLI Tool.
Stars: ✭ 207 (+1.97%)
Mutual labels:  cli, hash
Next Advanced Apollo Starter
Advanced, but minimalistic Next.js pre-configured starter with focus on DX
Stars: ✭ 131 (-35.47%)
Mutual labels:  zeit, nextjs
now-course
Proyecto para el curso de Now.sh en Platzi
Stars: ✭ 19 (-90.64%)
Mutual labels:  nextjs, zeit
Covid19 Brazil Api
API com dados atualizados sobre o status do COVID-19 🦠
Stars: ✭ 300 (+47.78%)
Mutual labels:  zeit, nextjs
server-authentication-next.js
No description or website provided.
Stars: ✭ 103 (-49.26%)
Mutual labels:  nextjs, zeit
Nookies
🍪 A set of cookie helpers for Next.js
Stars: ✭ 1,035 (+409.85%)
Mutual labels:  zeit, nextjs
Terraform Nextjs Plugin
A plugin to generate terraform configuration for Nextjs 8 and 9
Stars: ✭ 41 (-79.8%)
Mutual labels:  cli, nextjs
Next Go
Production ready blog + boilerplate for Next.js 3.X
Stars: ✭ 254 (+25.12%)
Mutual labels:  zeit, nextjs
Ran
⚡ RAN! React . GraphQL . Next.js Toolkit ⚡ - SEO-Ready, Production-Ready, SSR, Hot-Reload, CSS-in-JS, Caching, CLI commands and more...
Stars: ✭ 2,128 (+948.28%)
Mutual labels:  zeit, nextjs
Swr
React Hooks for data fetching
Stars: ✭ 20,348 (+9923.65%)
Mutual labels:  zeit, nextjs
Superplate
Performance-oriented frontend application creator with popular tools.
Stars: ✭ 368 (+81.28%)
Mutual labels:  cli, nextjs
Nextjs Vercel Firebase
Next.js app using API routes to connect with Firestore.
Stars: ✭ 133 (-34.48%)
Mutual labels:  zeit, nextjs
Dcipher Cli
🔓Crack hashes using online rainbow & lookup table attack services, right from your terminal.
Stars: ✭ 193 (-4.93%)
Mutual labels:  cli, hash
Survey
A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
Stars: ✭ 2,843 (+1300.49%)
Mutual labels:  cli
Addons Linter
🔍 Firefox Add-ons linter, written in JavaScript. 👁
Stars: ✭ 202 (-0.49%)
Mutual labels:  cli
Askgit
Query git repositories with SQL. Generate reports, perform status checks, analyze codebases. 🔍 📊
Stars: ✭ 2,707 (+1233.5%)
Mutual labels:  cli
Tty
Toolkit for developing sleek command line apps.
Stars: ✭ 2,329 (+1047.29%)
Mutual labels:  cli

next-build-id

Use a consistent, git-based build id for your Next.js app

Build Status Coverage Status JavaScript Style Guide Conventional Commits Greenkeeper badge

Small package to generate a consistent, git-based build id for your Next.js app when running next build on each server in a multi-server deployment.

This module exports a function that you can use as your generateBuildId config option in next.config.js.

By default, it will use the latest git commit hash from the local git repository (equivalent of git rev-parse HEAD):

// next.config.js
const nextBuildId = require('next-build-id')
module.exports = {
  generateBuildId: () => nextBuildId({ dir: __dirname })
}
// => 'f9fc968afa249d162c924a8d5b4ce6562c164c2e'

If you'd rather use a build id relative to the most recent tag in your git repo, pass describe: true as an option and the output of git describe --tags will be used instead:

// next.config.js
const nextBuildId = require('next-build-id')
module.exports = {
  generateBuildId: () => nextBuildId({ dir: __dirname, describe: true })
}
// => 'v1.0.0' (no changes since v1.0.0 tag)
// => 'v1.0.0-19-ga8f7eee' (19 changes since v1.0.0 tag)

This module also exposes a synchronous version for custom needs, e.g. passing the build id directly to a Sentry configuration. Just call nextBuildId.sync({ dir: __dirname }) instead.

Why?

If you're running multiple instances of your app sitting behind a load balancer without session affinity (and you're building your app directly on each production server instead of pre-packaging it), a tool like this is necessary to avoid Next.js errors like "invalid build file hash", which happens when the same client (browser code) talks to multiple server backends (Node server) that have different build ids.

The build id used by your app is stored on the file system in a BUILD_ID text file in your build directory, which is .next by default.

Install

$ npm i next-build-id

API

This module exports two functions, one that is asynchronous (nextBuildId() primary export) and one that is synchronous (nextBuildId.sync()). Both functions accept a single options object, supporting the same options listed below. Both functions return (or resolve to) a string, representing the git-based build id.

The options supported are:

  • dir (string, default process.cwd()): a directory within the local git repository

    Using __dirname from your next.config.js module is generally safe. The default value is assumed to be the directory from which you are running the next build command, but this may not be correct based on how you build your Next.js app.

  • describe (boolean, default false): use git tag description instead of latest commit sha

    Specify this as true to use git describe --tags instead of git rev-parse HEAD for generating the build id. If there are no tags in your local git repository, the latest commit sha will be used instead, unless you also specify fallbackToSha: false.

  • fallbackToSha (boolean, default true): fallback to latest commit sha when describe: true and no tags exist

    Only applies when using describe: true. If you want to be strict about requiring the use (and presence) of tags, then disable this with fallbackToSha: false, in which case an error will be thrown if no tags exist.

Note that this module really provides a generic way to get an id or status string for any local git repository, meaning it is not directly tied to Next.js in any way - it just depends on how you use it.

Reference

License

ISC © Andrew Goode

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].