Skip to content

Commit

Permalink
feat(repo): Add push and replace props to ClerkProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
desiprisg committed Nov 22, 2023
1 parent 5b5e1c4 commit 9e9b31f
Show file tree
Hide file tree
Showing 19 changed files with 219 additions and 67 deletions.
5 changes: 5 additions & 0 deletions .changeset/gold-islands-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/nextjs': major
---

Fix a bug where navigating from the sign in page to the sign up page required two back button presses to go back.
9 changes: 9 additions & 0 deletions .changeset/smart-suns-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'gatsby-plugin-clerk': major
'@clerk/clerk-js': major
'@clerk/nextjs': major
'@clerk/remix': major
'@clerk/types': major
---

Use the new `push` and `replace` props for `<ClerkProvider />` instead of `navigate`.
5 changes: 5 additions & 0 deletions .changeset/stupid-suits-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/types': major
---

Introduces two new props for `<ClerkProvider />`, `push` and `replace`. These props replace the `navigate` prop. Passing both `push` and `replace` will allow Clerk to correctly handle navigations without causing issues with the host application's router.
2 changes: 1 addition & 1 deletion integration/templates/react-vite/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Root = () => {
// @ts-ignore
publishableKey={import.meta.env.VITE_CLERK_PUBLISHABLE_KEY as string}
clerkJSUrl={import.meta.env.VITE_CLERK_JS as string}
navigate={(to: string) => navigate(to)}
push={(to: string) => navigate(to)}
>
<Outlet />
</ClerkProvider>
Expand Down
120 changes: 120 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/chrome-extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function ClerkProviderWithRoutes() {
return (
<ClerkProvider
publishableKey={publishableKey}
navigate={to => navigate(to)}
push={to => navigate(to)}
>
<Routes>
<Route
Expand Down
16 changes: 8 additions & 8 deletions packages/clerk-js/src/core/clerk.redirects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ describe('Clerk singleton - Redirects', () => {

clerkForProductionInstance = new Clerk(productionPublishableKey);
await clerkForProductionInstance.load({
navigate: mockNavigate,
push: mockNavigate,
});

clerkForDevelopmentInstance = new Clerk(developmentPublishableKey);
await clerkForDevelopmentInstance.load({
navigate: mockNavigate,
push: mockNavigate,
});
});

Expand Down Expand Up @@ -193,12 +193,12 @@ describe('Clerk singleton - Redirects', () => {

clerkForProductionInstance = new Clerk(productionPublishableKey);
await clerkForProductionInstance.load({
navigate: mockNavigate,
push: mockNavigate,
});

clerkForDevelopmentInstance = new Clerk(developmentPublishableKey);
await clerkForDevelopmentInstance.load({
navigate: mockNavigate,
push: mockNavigate,
});
});

Expand Down Expand Up @@ -284,12 +284,12 @@ describe('Clerk singleton - Redirects', () => {

clerkForProductionInstance = new Clerk(productionPublishableKey);
await clerkForProductionInstance.load({
navigate: mockNavigate,
push: mockNavigate,
});

clerkForDevelopmentInstance = new Clerk(developmentPublishableKey);
await clerkForDevelopmentInstance.load({
navigate: mockNavigate,
push: mockNavigate,
});
});

Expand Down Expand Up @@ -317,12 +317,12 @@ describe('Clerk singleton - Redirects', () => {

clerkForProductionInstance = new Clerk(productionPublishableKey);
await clerkForProductionInstance.load({
navigate: mockNavigate,
push: mockNavigate,
});

clerkForDevelopmentInstance = new Clerk(developmentPublishableKey);
await clerkForDevelopmentInstance.load({
navigate: mockNavigate,
push: mockNavigate,
});
});

Expand Down
Loading

0 comments on commit 9e9b31f

Please sign in to comment.