vercel/next.js · error
Route ${workStore.route} used "${expression}" inside `after(
Error message
Route ${workStore.route} used "${expression}" inside `after()`. The enabled status of `draftMode()` can be read inside `after()` but you cannot enable or disable `draftMode()`. See more info here: https://nextjs.org/docs/app/api-reference/functions/after What it means
Error "Route ${workStore.route} used "${expression}" inside `after()`. The enabled status of `draftMode()` can be read inside `after()` but you cannot enable or disable `draftMode()`. See more info here: https://nextjs.org/docs/app/api-reference/functions/after" thrown in vercel/next.js.
Source
Thrown at packages/next/src/server/request/draft-mode.ts:202
expression: string
) {
const prefix = route ? `Route "${route}" ` : 'This route '
return new Error(
`${prefix}used ${expression}. ` +
`\`draftMode()\` returns a Promise and must be unwrapped with \`await\` or \`React.use()\` before accessing its properties. ` +
`Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis`
)
}
function trackDynamicDraftMode(expression: string, constructorOpt: Function) {
const workStore = workAsyncStorage.getStore()
const workUnitStore = workUnitAsyncStorage.getStore()
if (workStore) {
// We have a store we want to track dynamic data access to ensure we
// don't statically generate routes that manipulate draft mode.
if (workUnitStore?.phase === 'after') {
throw new Error(
`Route ${workStore.route} used "${expression}" inside \`after()\`. The enabled status of \`draftMode()\` can be read inside \`after()\` but you cannot enable or disable \`draftMode()\`. See more info here: https://nextjs.org/docs/app/api-reference/functions/after`
)
}
if (workStore.dynamicShouldError) {
throw new StaticGenBailoutError(
`Route ${workStore.route} with \`dynamic = "error"\` couldn't be rendered statically because it used \`${expression}\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering`
)
}
if (workUnitStore) {
switch (workUnitStore.type) {
case 'cache':
case 'private-cache': {
const error = createDraftModeMutationInUseCacheError(
workStore.route,
expression
)View on GitHub (pinned to 258b1c1bc0)
Solutions
- Only read draftMode().isEnabled inside after(); do not call enable()/disable() there.
Defensive patterns
Strategy: validation
When it happens
Trigger: draftMode enable/disable is called inside after().
Common situations: Trying to mutate draft mode within an after() callback; only reading is allowed.
AI-assisted analysis of vercel/next.js@258b1c1bc0 (2026-08-19).
Data as JSON: /api/errors/d1f7974d59249673.
Report an issue: GitHub.