{"record":{"id":"18db1a707762a7ca","repo":"remix-run/react-router","slug":"you-cannot-use-navigator-back-on-the-server-beca","errorCode":null,"errorMessage":"You cannot use navigator.back() on the server because it is a stateless environment.","messagePattern":"You cannot use navigator\\.back\\(\\) on the server because it is a stateless environment\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/react-router/lib/dom/server.tsx","lineNumber":319,"sourceCode":"      );\n    },\n    replace(to: To) {\n      throw new Error(\n        `You cannot use navigator.replace() on the server because it is a stateless ` +\n          `environment. This error was probably triggered when you did a ` +\n          `\\`navigate(${JSON.stringify(to)}, { replace: true })\\` somewhere ` +\n          `in your app.`,\n      );\n    },\n    go(delta: number) {\n      throw new Error(\n        `You cannot use navigator.go() on the server because it is a stateless ` +\n          `environment. This error was probably triggered when you did a ` +\n          `\\`navigate(${delta})\\` somewhere in your app.`,\n      );\n    },\n    back() {\n      throw new Error(\n        `You cannot use navigator.back() on the server because it is a stateless ` +\n          `environment.`,\n      );\n    },\n    forward() {\n      throw new Error(\n        `You cannot use navigator.forward() on the server because it is a stateless ` +\n          `environment.`,\n      );\n    },\n  };\n}\n\n/**\n * Create a static {@link DataRouter} for server-side rendering\n *\n * @example\n * export async function handleRequest(request: Request) {","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/remix-run/react-router/blob/7aea711dd1ae2bc5a076d13ff17291829690fa74/packages/react-router/lib/dom/server.tsx#L301-L337","documentation":"The SSR stateless navigator implements back() as a throwing stub (lib/dom/server.tsx:290) because server rendering cannot move in browser history. This variant fires when code calls navigator.back()/router-level back navigation during SSR rather than the hook-wrapped push/replace forms.","triggerScenarios":"Custom code or a third-party library calling navigator.back() on the static router's navigator during SSR; router helpers that map UI intents to back()/forward() executing during the server render pass.","commonSituations":"Router-adjacent libraries (analytics, mobile bridges) driving back navigation at init time; wrappers around router.state.navigator used in isomorphic components.","solutions":["Only invoke back()/forward() from client-side event handlers","Pass an explicit fallback destination so SSR can redirect from a loader instead","Keep direct navigator access out of isomorphic code paths"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const isServer = typeof window === 'undefined';\nif (!isServer) navigator.back?.(); // client-only back navigation","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never touch router.state.navigator from isomorphic code","Init third-party navigation libraries only on the client","Prefer useNavigate()/Link instead of raw navigator methods"],"tags":["ssr","navigation","history","stateless-navigator"],"backgroundTag":"navigation-during-ssr","analyzedSha":"7aea711dd1ae2bc5a076d13ff17291829690fa74","analyzedAt":"2026-08-18T18:04:14.938Z","contentChangedAt":"2026-08-18T18:04:14.938Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}