summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/dirty-teachers-know.md5
-rw-r--r--packages/astro/src/transitions/router.ts2
2 files changed, 6 insertions, 1 deletions
diff --git a/.changeset/dirty-teachers-know.md b/.changeset/dirty-teachers-know.md
new file mode 100644
index 000000000..951117fff
--- /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 2be12895e..cb5476a7a 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 },