Skip to content
33 changes: 33 additions & 0 deletions src/content/docs/en/guides/upgrade-to/v6.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,39 @@ If you want to keep the old ID generation for backward compatibility reasons, yo

<ReadMore>Learn more about [Heading IDs](/en/guides/markdown-content/#heading-ids).</ReadMore>

### Changed: numbers are no longer allowed in `params` returned by `getStaticPaths()`.

<SourcePR number="14586" title="fix!: disallow number in getStaticPaths params"/>

Previously, `getStaticPaths()` could return `params` with number values. However, at runtime `Astro.params` values are always strings or undefined because they come from URL segments. This change removes that mismatch so the types reflect runtime behavior.

#### What should I do?

In the returned `params` object from `getStaticPaths()`, convert any numbers to strings (for example, `String(id)`).

```diff
---
// src/pages/post/[id]/[label].astro
export function getStaticPaths() {
return [
{
params: {
- id: 1,
+ id: "1",
label: "foo",
}
},
{
params: {
- id: 2,
+ id: "2",
label: "bar",
}
},
]
}
---

## Community Resources

Know a good resource for Astro v5.0? [Edit this page](https://github.com/withastro/docs/edit/main/src/content/docs/en/guides/upgrade-to/v6.mdx) and add a link below!
Expand Down