mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Keep reading `config.experimental.outputHashSalt` for now to not break existing adapters until they are migrated.
32 lines
1.3 KiB
Plaintext
32 lines
1.3 KiB
Plaintext
---
|
|
title: outputHashSalt
|
|
description: Learn how to incorporate a custom salt string into content-addressed output filenames.
|
|
---
|
|
|
|
`outputHashSalt` is an option that incorporates a configurable salt string into every content-addressed output filename (chunks, assets). Changing this value forces all output hashes to change, which is useful for invalidating cached assets across deployments without modifying source files.
|
|
|
|
To configure the output hash salt, set `outputHashSalt` in `next.config.js`:
|
|
|
|
```js filename="next.config.js"
|
|
/** @type {import('next').NextConfig} */
|
|
const nextConfig = {
|
|
outputHashSalt: 'my-deployment-salt',
|
|
}
|
|
|
|
module.exports = nextConfig
|
|
```
|
|
|
|
This works with both Webpack and Turbopack bundlers.
|
|
|
|
The `NEXT_HASH_SALT` environment variable can also be used for the same purpose. When both are set, the values are **concatenated** (`outputHashSalt + NEXT_HASH_SALT`) to form the effective salt. This lets you combine a per-project salt baked into the config with a per-deployment salt injected at build time via environment variable.
|
|
|
|
```bash filename="Terminal"
|
|
NEXT_HASH_SALT=my-deployment-salt next build
|
|
```
|
|
|
|
## Version History
|
|
|
|
| Version | Changes |
|
|
| -------- | --------------------------- |
|
|
| `16.3.0` | `outputHashSalt` was added. |
|