remix-run/react-router · error
The route at ${_match.route.path} returns an invalid value.
Error message
The route at ${_match.route.path} returns an invalid value. All route meta functions must return an array of meta objects.
To reference the meta function API, see https://reactrouter.com/start/framework/route-module#meta What it means
React Router framework mode requires a route module's `meta` export to be either a function that returns an array of meta descriptor objects, or a plain array of such objects. While building the UIMatch meta for the matched routes, this code copies the leaf route's meta result and throws if the final value is not an array (a falsy return is fine and treated as empty). The message includes the offending route's path so you can locate the bad export.
Source
Thrown at packages/react-router/lib/dom/ssr/components.tsx:662
loaderData: data,
params,
location,
matches,
error,
})
: Array.isArray(routeModule.meta)
? [...routeModule.meta]
: routeModule.meta;
} else if (leafMeta) {
// We only assign the route's meta to the nearest leaf if there is no meta
// export in the route. The meta function may return a falsy value which
// is effectively the same as an empty array.
routeMeta = [...leafMeta];
}
routeMeta = routeMeta || [];
if (!Array.isArray(routeMeta)) {
throw new Error(
"The route at " +
_match.route.path +
" returns an invalid value. All route meta functions must " +
"return an array of meta objects." +
"\n\nTo reference the meta function API, see https://reactrouter.com/start/framework/route-module#meta",
);
}
match.meta = routeMeta;
matches[i] = match;
meta = [...routeMeta];
leafMeta = meta;
}
return (
<>
{meta.flat().map((metaProps) => {
if (!metaProps) {View on GitHub (pinned to 6beaca3952)
Solutions
- Change the meta export in the route named in the error to return an array: `export const meta = () => [{ title: "My Page" }]`.
- If meta is a static export, make it an array of objects: `export const meta = [{ title: "My Page" }]`.
- Verify every branch of a conditional meta function returns an array (never a bare object or string).
- After fixing, restart the dev server / rebuild so route modules are reloaded.
Example fix
// before
export const meta = () => ({
title: "Dashboard",
});
// after
export const meta = () => [
{ title: "Dashboard" },
]; Defensive patterns
Strategy: validation
Validate before calling
// dev-time check in the route module
export const meta: MetaFunction = () => {
const tags = [{ title: "Page" }];
if (!Array.isArray(tags)) throw new TypeError("meta must return an array");
return tags;
}; Type guard
const isMetaDescriptors = (v: unknown): v is MetaDescriptor[] => Array.isArray(v) && v.every((t) => t != null && typeof t === "object");
Prevention
- Type every meta export as MetaFunction so TypeScript enforces the array return.
- Always wrap descriptors in [...] even for single-item returns.
- Run the route once in dev before shipping; this error only appears at runtime for the matched route.
When it happens
Trigger: Exporting `meta = () => ({ title: "..." })` (an object instead of an array), returning a single object like `{ title, description }` from the meta function, returning a string or undefined-but-truthy non-array, or exporting meta as a non-array static value that is neither array nor function.
Common situations: Migrating from hand-rolled <meta> tags or from Remix examples where meta returned an object; refactoring a meta function to conditionally return `{ ...spread }` instead of `[...]`; TypeScript not catching it when the route module is loosely typed; only surfacing at runtime on the first request/render of that route.
Related errors
- A meta object uses an invalid tagName: ${tagName}. Expected
- package.json ${pkgKey} are invalid
- React Router presets must have a `name` property defined.
- Could not find package.json in ${rootDirectory} or any of it
- Unable to define routes with duplicate route id: "${id}"
AI-assisted analysis of remix-run/react-router@6beaca3952 (2026-08-18).
Data as JSON: /api/errors/e7cc04ab396b843c.
Report an issue: GitHub.