{"record":{"id":"e16a4d456f662945","repo":"vercel/next.js","slug":"unstable-isunrecognizedactionerror-can-only-be-u","errorCode":null,"errorMessage":"`unstable_isUnrecognizedActionError` can only be used on the client.","messagePattern":"`unstable_isUnrecognizedActionError` can only be used on the client\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/client/components/navigation.react-server.ts","lineNumber":4,"sourceCode":"import { ReadonlyURLSearchParams } from './readonly-url-search-params'\n\nexport function unstable_isUnrecognizedActionError(): boolean {\n  throw new Error(\n    '`unstable_isUnrecognizedActionError` can only be used on the client.'\n  )\n}\n\nexport { redirect, permanentRedirect } from './redirect'\nexport { notFound } from './not-found'\nexport { forbidden } from './forbidden'\nexport { unauthorized } from './unauthorized'\nexport { unstable_rethrow } from './unstable-rethrow'\nexport { ReadonlyURLSearchParams }\n\nexport const RedirectType = {\n  push: 'push',\n  replace: 'replace',\n} as const\n","sourceCodeStart":1,"sourceCodeEnd":20,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/client/components/navigation.react-server.ts#L1-L20","documentation":"This error is thrown by the server-component stub of `unstable_isUnrecognizedActionError`. Next.js ships two implementations of the function: the real one in `unrecognized-action-error.ts` (client-only, checks `error instanceof UnrecognizedActionError`) and a `.react-server` variant in `navigation.react-server.ts` whose body unconditionally throws. The throw exists because detecting an unrecognized-action error requires the `UnrecognizedActionError` class, which is only meaningful in the browser bundle; calling it from a Server Component is a programming error.","triggerScenarios":"Importing `unstable_isUnrecognizedActionError` from `next/navigation` inside a Server Component, a Route Handler running in the RSC context, or any module that resolves the `.react-server` condition. The function executes its stub body at line 3-7, which always throws regardless of arguments.","commonSituations":"Copying a try/catch snippet from the docs into a Server Component instead of a Client Component; sharing an error-handling utility module between server and client files where the import resolves to the server variant; upgrading Next.js and not realizing the function is client-only.","solutions":["Move the `unstable_isUnrecognizedActionError` call into a Client Component ('use client') so the import resolves to the real implementation in navigation.ts.","If you must handle the error on the server, rethrow or re-surface it instead — the server never receives an UnrecognizedActionError, so the check is meaningless there.","Audit import paths: ensure the file calling the function has the 'use client' directive at the top."],"exampleFix":"// before (Server Component — throws)\nimport { unstable_isUnrecognizedActionError } from 'next/navigation'\n\nexport default async function Page() {\n  try { await action() }\n  catch (e) { if (unstable_isUnrecognizedActionError(e)) {} }\n}\n\n// after (Client Component)\n'use client'\nimport { unstable_isUnrecognizedActionError } from 'next/navigation'\n\nexport function ActionButton() {\n  try { await action() }\n  catch (e) { if (unstable_isUnrecognizedActionError(e)) { window.location.reload() } }\n}","handlingStrategy":"type-guard","validationCode":"// Ensure the calling file is a Client Component before importing.\n// Check for the directive at the top of the file:\n// 'use client'\n// If absent, do not import unstable_isUnrecognizedActionError.","typeGuard":"// The real guard lives in navigation.ts (client). On the server,\n// there is nothing to guard — avoid the import entirely.\nfunction isClientContext(): boolean {\n  return typeof window !== 'undefined'\n}","tryCatchPattern":null,"preventionTips":["Keep 'use client' directive at the top of any file that imports client-only navigation utilities.","Separate server and client error-handling code into different files to prevent cross-environment imports.","When copying error-handling snippets from docs, verify the intended execution environment."],"tags":["server-components","client-components","app-router","server-actions"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}