diff --git a/packages/clerk-js/src/ui/router/PathRouter.tsx b/packages/clerk-js/src/ui/router/PathRouter.tsx index 2d369c434a5..41112a41ff9 100644 --- a/packages/clerk-js/src/ui/router/PathRouter.tsx +++ b/packages/clerk-js/src/ui/router/PathRouter.tsx @@ -38,7 +38,8 @@ export const PathRouter = ({ basePath, preservedParams, children }: PathRouterPr const convertHashToPath = async () => { if (hasUrlInFragment(window.location.hash)) { const url = mergeFragmentIntoUrl(new URL(window.location.href)); - await internalNavigate(url.href); + window.history.replaceState(window.history.state, '', url.href); + await internalNavigate(url.href); // make this navigation as well since replaceState is asynchronous setStripped(true); } }; diff --git a/packages/clerk-js/src/ui/router/__tests__/PathRouter.test.tsx b/packages/clerk-js/src/ui/router/__tests__/PathRouter.test.tsx index e68004d422b..6ac471d5497 100644 --- a/packages/clerk-js/src/ui/router/__tests__/PathRouter.test.tsx +++ b/packages/clerk-js/src/ui/router/__tests__/PathRouter.test.tsx @@ -54,6 +54,7 @@ describe('PathRouter', () => { beforeAll(() => { // @ts-ignore delete window.location; + history.replaceState = jest.fn(); }); afterAll(() => {