Capítulo 282 de 456
When enabled, Next.js emits content-addressed static assets under /_next/static/immutable/* that live in a shared namespace across deployments (no ?dpl query param); an adapter opts in via config and uses immutableHash to detect/prevent hash collisions.
config.supportsImmutableAssets: adapter sets this to true in modifyConfig (unless the user explicitly opted out) to signal support for deploying immutable assets.outputs.staticFiles[].immutableHash: full content hash for a static file; present only for immutable assets. Next.js may truncate the filename hash, so this field validates no collision occurred.config.outputHashSalt: salt for content hashes, used to rotate hashes (e.g. after a detected collision).?dpl query parameter, scoped per deployment (e.g. public folder files, or older Next.js versions) — must remain supported alongside immutable ones./** @type {import('next').NextAdapter} */
const adapter = {
name: 'my-custom-adapter',
async modifyConfig(config, { phase }) {
if (phase === 'phase-production-build') {
config.supportsImmutableAssets = config.supportsImmutableAssets ?? true
// config.outputHashSalt = getSaltForCurrentProject()
}
return config
},
async onBuildComplete({ outputs }) {
for (const output of outputs.staticFiles) {
if (output.immutableHash != null) {
// Must be requestable at output.pathname even without ?dpl
uploadOrVerifyImmutableStaticAsset(
output.filePath,
output.pathname,
output.immutableHash
)
} else {
uploadStaticAsset(output.filePath, output.pathname)
}
}
},
}
modifyConfig seguido do branch immutable-vs-non-immutable ao processar outputs.staticFiles em onBuildComplete.public folder and older Next.js versions requested with ?dpl.config.supportsImmutableAssets = true in modifyConfig, (2) branch on immutableHash != null in onBuildComplete to decide upload strategy.?dpl query param, since they're shared across deployments by content hash.outputHashSalt is the escape hatch for rotating hashes after a collision, not a routine config knob.STATIC_FILE shape including immutableHash.NEXT_SUPPORTS_IMMUTABLE_ASSETS marker the logs script must emit.