sveltejs/kit · error
Mismatched route config for ${route.id} — the +page and +ser
Error message
Mismatched route config for ${route.id} — the +page and +server files must export the same config, if any What it means
When a route has both +page and +server files, SvelteKit requires any page-level `export const config` and endpoint-level `export const config` to match exactly. JSON-unequal configs for the same key cause this error, because one route cannot carry two different configurations.
Source
Thrown at packages/kit/src/core/postbuild/analyse.js:108
// analyse routes
for (const route of manifest.routes) {
const page =
route.page &&
analyse_page(
route.page.layouts.map((n) => (n === undefined ? n : nodes[n])),
nodes[route.page.leaf]
);
const endpoint = route.endpoint && analyse_endpoint(route, await route.endpoint());
if (page?.prerender && endpoint?.prerender) {
throw new Error(`Cannot prerender a route with both +page and +server files (${route.id})`);
}
if (page?.config && endpoint?.config) {
for (const key in { ...page.config, ...endpoint.config }) {
if (JSON.stringify(page.config[key]) !== JSON.stringify(endpoint.config[key])) {
throw new Error(
`Mismatched route config for ${route.id} — the +page and +server files must export the same config, if any`
);
}
}
}
const route_config = page?.config ?? endpoint?.config ?? {};
const prerender = page?.prerender ?? endpoint?.prerender;
if (prerender !== true) {
for (const feature of list_features(
route,
manifest_data,
server_manifest,
tracked_features
)) {
check_feature(route.id, route_config, feature, config.adapter);
}View on GitHub (pinned to 03f1687fe6)
Solutions
- Make the `config` exports in +page.js and +server.js identical (deep-equal) for that route.
- Or remove `config` from one of the files if it's only meaningful for one side's deployment.
- If the page and endpoint truly need different configs, split them into different route directories.
Example fix
// before (+server.js)
export const config = { runtime: 'experimental_node' };
// after (match +page.js)
export const config = { runtime: 'nodejs20' }; Defensive patterns
Strategy: validation
Validate before calling
const pageConfig = (await import('./src/routes/demo/+page.js')).config;
const serverConfig = (await import('./src/routes/demo/+server.js')).config;
if (pageConfig && serverConfig &&
JSON.stringify(pageConfig) !== JSON.stringify(serverConfig)) {
throw new Error('+page and +server config exports must be identical');
} Try / catch
try {
await build();
} catch (e) {
if (String(e.message).includes('Mismatched route config')) {
console.error('Sync the `config` exports between +page.js and +server.js in:', e.message);
} else throw e;
} Prevention
- Keep a single shared constant (e.g. export const config from a common module) imported by both files.
- After editing adapter-specific config, update both +page and +server in mixed routes.
- Review git diffs of one side for a route directory to catch the other side needing the same change.
When it happens
Trigger: A route directory with +page.js exporting `config = { runtime: 'edge' }` and +server.js exporting a different `config` (different values, or one side missing a key the other has, when both define config).
Common situations: Adapter-specific configs (e.g. Cloudflare/Vercel runtime) diverging between +page and +server during iterative edits; one teammate updating page config but not the server config.
Related errors
- Page options are ignored when `router.type === 'hash'` (${no
- Cannot prerender a route with both +page and +server files (
- No matcher found for parameter '${name}'${file ? ` in ${file
- To suppress or handle this error, implement `${name}` in htt
- precompress is ignored with buildOptions.compile: embedded a
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/1d857b33eb2c8c2c.
Report an issue: GitHub.