Astro throws “Missing params property on getStaticPaths() route” when an object returned from getStaticPaths() has no params key, or params is an empty object. The message reads: “Missing or empty required params property on getStaticPaths() route.” Every route needs params with one key per bracket in the file name, so [slug].astro needs { params: { slug: '...' } }.
Key Takeaways
- Every route object needs a non-empty
params.- The key names must match the bracket names exactly, including case.
- A typo like
param(singular) orparmascauses this error.- Conditional logic that sometimes skips
paramswill fail on the first bad entry.
Reproduce and fix
// src/pages/blog/[slug].astro
// Wrong: no params at all
return posts.map((post) => ({ props: { post } }));
// Wrong: typo in the key
return posts.map((post) => ({ param: { slug: post.id }, props: { post } }));
// Right
return posts.map((post) => ({ params: { slug: post.id }, props: { post } }));
When some entries are skipped
A common pattern builds params conditionally:
return posts.map((post) => post.data.slug
? { params: { slug: post.data.slug }, props: { post } }
: { props: { post } }, // missing params for posts without a custom slug
);
Fall back to the id instead:
return posts.map((post) => ({
params: { slug: post.data.slug ?? post.id },
props: { post },
}));
Or filter out entries before mapping:
return posts
.filter((post) => post.data.slug)
.map((post) => ({ params: { slug: post.data.slug }, props: { post } }));
Param names must match the file
For src/pages/[category]/[slug].astro, returning only { slug } leaves category undefined and the route can’t be built. Include every bracket:
return products.map((p) => ({
params: { category: p.data.category, slug: p.id },
props: { product: p },
}));
Using pagination?
paginate() builds params for you. If you combine it with extra params, pass them through its options:
return tags.flatMap((tag) =>
paginate(postsFor(tag), { params: { tag }, pageSize: 10 }),
);
Related fixes: invalid value returned from getStaticPaths() for wrong shapes, and getStaticPaths() required when the function is missing. The Astro routing guide walks through tag pages with pagination. See also the official error page.
FAQ
Is params optional for rest routes?
The params object is still required. For a rest parameter like [...path], the value inside can be undefined to serve the parent path.
Does Astro tell me which entry failed?
Not directly. Log the array before returning it, or add a .filter() that drops and logs entries without the value you need.