remix-run/react-router · error
You cannot use navigator.back() on the server because it is
Error message
You cannot use navigator.back() on the server because it is a stateless environment.
What it means
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.
Source
Thrown at packages/react-router/lib/dom/server.tsx:319
);
},
replace(to: To) {
throw new Error(
`You cannot use navigator.replace() on the server because it is a stateless ` +
`environment. This error was probably triggered when you did a ` +
`\`navigate(${JSON.stringify(to)}, { replace: true })\` somewhere ` +
`in your app.`,
);
},
go(delta: number) {
throw new Error(
`You cannot use navigator.go() on the server because it is a stateless ` +
`environment. This error was probably triggered when you did a ` +
`\`navigate(${delta})\` somewhere in your app.`,
);
},
back() {
throw new Error(
`You cannot use navigator.back() on the server because it is a stateless ` +
`environment.`,
);
},
forward() {
throw new Error(
`You cannot use navigator.forward() on the server because it is a stateless ` +
`environment.`,
);
},
};
}
/**
* Create a static {@link DataRouter} for server-side rendering
*
* @example
* export async function handleRequest(request: Request) {View on GitHub (pinned to 7aea711dd1)
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
Defensive patterns
Strategy: validation
Validate before calling
const isServer = typeof window === 'undefined'; if (!isServer) navigator.back?.(); // client-only back navigation
Prevention
- 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
When it happens
Trigger: 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.
Common situations: Router-adjacent libraries (analytics, mobile bridges) driving back navigation at init time; wrappers around router.state.navigator used in isomorphic components.
Related errors
- You cannot use navigator.go() on the server because it is a
- You cannot use navigator.forward() on the server because it
- You cannot use navigator.push() on the server because it is
- You cannot use navigator.replace() on the server because it
- Prerender (data): Received a ${response.status} status code
AI-assisted analysis of remix-run/react-router@7aea711dd1 (2026-08-18).
Data as JSON: /api/errors/18db1a707762a7ca.
Report an issue: GitHub.