sveltejs/kit · error · Error
Parameter values must be a string, number, boolean, or bigin
Error message
Parameter values must be a string, number, boolean, or bigint
What it means
`resolve_route` stringifies each parameter into the route path. Only strings, numbers, booleans, and bigints can be safely converted; any other value type (objects, arrays, null, undefined reaching this branch) is rejected with this error to prevent silently rendering `[object Object]` in URLs.
Source
Thrown at packages/kit/src/utils/routing.js:331
if (typeof value === 'string') {
if (value.startsWith('/') || value.endsWith('/')) {
throw new Error(
`Parameter '${name}' in route ${id} cannot start or end with a slash -- this would cause an invalid route like foo//bar`
);
}
return value;
}
if (
typeof value === 'number' ||
typeof value === 'boolean' ||
typeof value === 'bigint'
) {
return String(value);
}
throw new Error('Parameter values must be a string, number, boolean, or bigint');
})
)
.filter(Boolean)
.join('/') +
(has_id_trailing_slash ? '/' : '')
);
}
/**
* @param {import('types').SSRNode} node
* @returns {boolean}
*/
export function has_server_load(node) {
return node.server?.load !== undefined || node.server?.trailingSlash !== undefined;
}
/**
* Find the first route that matches the given pathView on GitHub (pinned to 03f1687fe6)
Solutions
- Stringify or otherwise convert the value before resolving (e.g. `String(obj.id)`, `date.toISOString()`)
- Ensure lookups that produce params cannot return null/undefined objects for required params
- Coerce booleans/numbers deliberately so only intended primitives reach resolution
Example fix
// before
resolve_route(id, pattern, { date: new Date('2024-01-01') });
// after
resolve_route(id, pattern, { date: '2024-01-01' }); Defensive patterns
Strategy: type-guard
Validate before calling
function isStringifiableParam(v) {
return typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' || typeof v === 'bigint';
}
Object.values(params).forEach((v) => { if (!isStringifiableParam(v)) throw new Error('param not primitive'); }); Type guard
function isParamValue(v) {
return ['string', 'number', 'boolean', 'bigint'].includes(typeof v);
} Try / catch
try {
const href = resolveRoute(id, pattern, params);
} catch (e) {
if (e.message.startsWith('Parameter values must be')) {
// stringify/serialize the offending param before resolving
}
throw e;
} Prevention
- Only pass primitives into route resolution
- Convert Dates/objects to ids or ISO strings upstream
- Guard against null from failed lookups before resolving
When it happens
Trigger: Resolving a route with a params object containing an object/array (e.g. `{ id: { value: 1 } }`), null, or a value type not covered by the earlier branches (and not handled as optional/rest).
Common situations: Passing parsed objects (Date, model instances) as params instead of their string/id representation; accidentally wrapping the param in an object; supplying null from failed data lookups.
Related errors
- Missing parameter '${name}' in route ${id}
- Parameter '${name}' in route ${id} cannot start or end with
- Invalid param definition
- Missing params for dynamic route ID ${id}
- No matcher found for parameter '${name}'${file ? ` in ${file
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/0b4578f17931c2b1.
Report an issue: GitHub.