diff --git a/.changeset/dirty-teachers-know.md b/.changeset/dirty-teachers-know.md new file mode 100644 index 000000000000..951117ffff1a --- /dev/null +++ b/.changeset/dirty-teachers-know.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes a potential null access in the clientside router diff --git a/packages/astro/src/transitions/router.ts b/packages/astro/src/transitions/router.ts index 2be12895e53f..cb5476a7a588 100644 --- a/packages/astro/src/transitions/router.ts +++ b/packages/astro/src/transitions/router.ts @@ -636,7 +636,7 @@ if (inBrowser) { 'scroll', () => { if (intervalId !== undefined) return; - (lastIndex = history.state.index), (lastY = scrollY), (lastX = scrollX); + (lastIndex = history.state?.index), (lastY = scrollY), (lastX = scrollX); intervalId = window.setInterval(scrollInterval, 50); }, { passive: true },