From d8cd16bcd4e9f656379bff6150af7329e4303a06 Mon Sep 17 00:00:00 2001 From: ocavue Date: Fri, 24 Oct 2025 00:17:16 +1100 Subject: [PATCH 1/9] [v6] disallow number in getStaticPaths params --- src/content/docs/en/guides/upgrade-to/v6.mdx | 33 ++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index bac4071d5915f..5b0b09dbbb3bc 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -840,6 +840,39 @@ If you want to keep the old ID generation for backward compatibility reasons, yo Learn more about [Heading IDs](/en/guides/markdown-content/#heading-ids). +### Changed: numbers are no longer allowed in `params` returned by `getStaticPaths()`. + + + +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! From be8e800e5380a5bdc2dfc1d2d67493442850d624 Mon Sep 17 00:00:00 2001 From: ocavue Date: Sat, 25 Oct 2025 01:32:28 +1100 Subject: [PATCH 2/9] Update src/content/docs/en/guides/upgrade-to/v6.mdx Co-authored-by: Florian Lefebvre --- src/content/docs/en/guides/upgrade-to/v6.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 5b0b09dbbb3bc..48dd7f43b6a3a 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -840,7 +840,7 @@ If you want to keep the old ID generation for backward compatibility reasons, yo Learn more about [Heading IDs](/en/guides/markdown-content/#heading-ids). -### Changed: numbers are no longer allowed in `params` returned by `getStaticPaths()`. +### Changed: `getStaticPaths()` cannot return `params` of type number From 88db8d7fa2387a19c1bf995edffb2d1e202902b3 Mon Sep 17 00:00:00 2001 From: ocavue Date: Sat, 25 Oct 2025 01:32:35 +1100 Subject: [PATCH 3/9] Update src/content/docs/en/guides/upgrade-to/v6.mdx Co-authored-by: Florian Lefebvre --- src/content/docs/en/guides/upgrade-to/v6.mdx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 48dd7f43b6a3a..df458f10d71b1 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -844,7 +844,9 @@ If you want to keep the old ID generation for backward compatibility reasons, yo -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. +In Astro 5.x, `getStaticPaths()` could return `params` of type number, which would always be stringified by Astro. However, that could be confusing because it conflicted with `Astro.params` types. + +Astro 6.0 removes this behavior: `getStaticPaths()` must now return string or undefined `params` values. #### What should I do? From 31e2a4027ca5b16d96ead4e8b6779e197dbdc716 Mon Sep 17 00:00:00 2001 From: ocavue Date: Sat, 25 Oct 2025 01:32:44 +1100 Subject: [PATCH 4/9] Update src/content/docs/en/guides/upgrade-to/v6.mdx Co-authored-by: Florian Lefebvre --- src/content/docs/en/guides/upgrade-to/v6.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index df458f10d71b1..98623550bf65e 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -850,7 +850,7 @@ Astro 6.0 removes this behavior: `getStaticPaths()` must now return string or un #### What should I do? -In the returned `params` object from `getStaticPaths()`, convert any numbers to strings (for example, `String(id)`). +Review your dynamic routing pages using `getStaticPaths()` and convert any number params to strings: ```diff --- From a6b0ed5e29d1ff5a2005ed6d9a5da484d7aa58de Mon Sep 17 00:00:00 2001 From: ocavue Date: Sat, 25 Oct 2025 01:32:52 +1100 Subject: [PATCH 5/9] Update src/content/docs/en/guides/upgrade-to/v6.mdx Co-authored-by: Florian Lefebvre --- src/content/docs/en/guides/upgrade-to/v6.mdx | 36 ++++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 98623550bf65e..27d4ca0858229 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -852,28 +852,28 @@ Astro 6.0 removes this behavior: `getStaticPaths()` must now return string or un Review your dynamic routing pages using `getStaticPaths()` and convert any number params to strings: -```diff +```astro title="src/pages/post/[id]/[label].astro" del={6,13} ins={7,14} --- -// src/pages/post/[id]/[label].astro export function getStaticPaths() { - return [ - { - params: { -- id: 1, -+ id: "1", - label: "foo", - } - }, - { - params: { -- id: 2, -+ id: "2", - label: "bar", - } - }, - ] + return [ + { + params: { + id: 1, + id: "1", + label: "foo", + } + }, + { + params: { + id: 2, + id: "2", + label: "bar", + } + }, + ] } --- +``` ## Community Resources From 9654590caa7481a7a150596710e9bafc3f08643e Mon Sep 17 00:00:00 2001 From: ocavue Date: Sat, 25 Oct 2025 01:32:59 +1100 Subject: [PATCH 6/9] Update src/content/docs/en/guides/upgrade-to/v6.mdx Co-authored-by: Florian Lefebvre --- src/content/docs/en/guides/upgrade-to/v6.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 27d4ca0858229..abef86e5e9fc0 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -875,6 +875,8 @@ export function getStaticPaths() { --- ``` +Learn more about [dynamic SSG routes with `getStaticPaths()`](https://docs.astro.build/en/guides/routing/#static-ssg-mode). + ## 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! From 6cd018b29534285286c1bdbbd2f88ab23b87d1f1 Mon Sep 17 00:00:00 2001 From: ocavue Date: Sat, 25 Oct 2025 01:41:26 +1100 Subject: [PATCH 7/9] Update src/content/docs/en/guides/upgrade-to/v6.mdx Co-authored-by: Florian Lefebvre --- src/content/docs/en/guides/upgrade-to/v6.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index abef86e5e9fc0..3454dd6b723db 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -850,7 +850,7 @@ Astro 6.0 removes this behavior: `getStaticPaths()` must now return string or un #### What should I do? -Review your dynamic routing pages using `getStaticPaths()` and convert any number params to strings: +Review your dynamic routes using `getStaticPaths()` and convert any number params to strings: ```astro title="src/pages/post/[id]/[label].astro" del={6,13} ins={7,14} --- From 476e2bdc48239fa847bc0d8705d12c4f443ae23b Mon Sep 17 00:00:00 2001 From: ocavue Date: Sat, 25 Oct 2025 04:22:59 +1100 Subject: [PATCH 8/9] Update src/content/docs/en/guides/upgrade-to/v6.mdx Co-authored-by: Armand Philippot --- src/content/docs/en/guides/upgrade-to/v6.mdx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 3454dd6b723db..8f03c01ce0d22 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -862,13 +862,13 @@ export function getStaticPaths() { id: "1", label: "foo", } - }, - { - params: { - id: 2, - id: "2", - label: "bar", - } + }, + { + params: { + id: 2, + id: "2", + label: "bar", + } }, ] } From 0b9596298b7e8c46593106370b127824a5630be9 Mon Sep 17 00:00:00 2001 From: ocavue Date: Sat, 25 Oct 2025 04:23:06 +1100 Subject: [PATCH 9/9] Update src/content/docs/en/guides/upgrade-to/v6.mdx Co-authored-by: Armand Philippot --- src/content/docs/en/guides/upgrade-to/v6.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/en/guides/upgrade-to/v6.mdx b/src/content/docs/en/guides/upgrade-to/v6.mdx index 8f03c01ce0d22..c40cdb499c5c5 100644 --- a/src/content/docs/en/guides/upgrade-to/v6.mdx +++ b/src/content/docs/en/guides/upgrade-to/v6.mdx @@ -875,7 +875,7 @@ export function getStaticPaths() { --- ``` -Learn more about [dynamic SSG routes with `getStaticPaths()`](https://docs.astro.build/en/guides/routing/#static-ssg-mode). +Learn more about [dynamic SSG routes with `getStaticPaths()`](/en/guides/routing/#static-ssg-mode). ## Community Resources