diff --git a/.changeset/thirty-dancers-wink.md b/.changeset/thirty-dancers-wink.md new file mode 100644 index 000000000000..dfe386f44d0e --- /dev/null +++ b/.changeset/thirty-dancers-wink.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Fixes an error when using `astro:transtions/client` without `` diff --git a/packages/astro/src/transitions/router.ts b/packages/astro/src/transitions/router.ts index 69f4e717c351..db5a5ea731e9 100644 --- a/packages/astro/src/transitions/router.ts +++ b/packages/astro/src/transitions/router.ts @@ -622,7 +622,7 @@ const onScrollEnd = () => { // "scrollend" events. To avoid redundant work and expensive calls to // `replaceState()`, we simply check that the values are different before // updating. - if (scrollX !== history.state.scrollX || scrollY !== history.state.scrollY) { + if (history.state && (scrollX !== history.state.scrollX || scrollY !== history.state.scrollY)) { updateScrollPosition({ scrollX, scrollY }); } };