-
Notifications
You must be signed in to change notification settings - Fork 338
feat(clerk-react,clerk-js, types,shared): Introduce Clerk.status
#5476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(clerk-react,clerk-js, types,shared): Introduce Clerk.status
#5476
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
…clerk-has-failed-to-load-from # Conflicts: # packages/react/src/isomorphicClerk.ts
🦋 Changeset detectedLatest commit: b04005d The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The inline script might fail before the event listeners are attached which causes an infinite pending state. Instead, we would like to retry fetching the script and/or throw an error.
This reverts commit 129d423.
…clerk-has-failed-to-load-from # Conflicts: # packages/clerk-js/src/core/auth/AuthCookieService.ts
…clerk-has-failed-to-load-from
…clerk-has-failed-to-load-from # Conflicts: # packages/clerk-js/bundlewatch.config.json
…clerk-has-failed-to-load-from
!snapshot |
…clerk-has-failed-to-load-from
…clerk-has-failed-to-load-from
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new status tracking property for Clerk, allowing developers to distinguish between different operational states ("loading", "error", "ready", and "degraded"). It updates the core Clerk implementation, React hooks, context providers, and UI components to leverage the new Clerk.status and adjust the computed loaded flag accordingly.
- Adds a new Clerk.status property with corresponding event handling.
- Refactors many loading checks across the SDK to use Clerk.status.
- Introduces new React components ( and ) and updates tests/documentation to support the new status logic.
Reviewed Changes
Copilot reviewed 20 out of 24 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
packages/react/src/isomorphicClerk.ts | Introduces Clerk.status, replaces internal loaded checks |
packages/react/src/hooks/utils.ts | Updates event listener to use Clerk.status |
packages/react/src/contexts/ClerkContextProvider.tsx | Refactors context to derive state from Clerk.status |
packages/react/src/components/* | Adjusts control components to render based on the new status |
packages/nextjs/* | Updates Next.js integrations similarly |
packages/clerk-js/src/core/* | Revises the core Clerk logic and error handling to emit proper status |
integration/tests/* | Adds tests to verify correct status transitions |
.changeset/* | Updates changesets to document the new status feature |
Files not reviewed (4)
- .typedoc/tests/snapshots/file-structure.test.ts.snap: Language not supported
- packages/chrome-extension/src/tests/snapshots/exports.test.ts.snap: Language not supported
- packages/clerk-js/bundlewatch.config.json: Language not supported
- packages/react-router/src/tests/snapshots/exports.test.ts.snap: Language not supported
…clerk-has-failed-to-load-from # Conflicts: # integration/testUtils/index.ts
Description
Introduce
useClerk().status
,Clerk.status
alongside<ClerkFailed/>
and<ClerkDegraded/>
.useClerk().status
Possible values are:
loading
(initial state)error
set when hotloading clerk-js failed orClerk.load()
failedready
set when Clerk is fully operationaldegraded
set when Clerk is partially operationaluseClerk().loaded
istrue
whenuseClerk().status
is either"ready"
or"degraded"
.useClerk().loaded
isfalse
whenuseClerk().status
is"loading"
or"error"
.Important
🚨🚨
Clerk.status
becomesloading
upon instantiation not upon calling.load()
New APIs
on()
Calls handler on every status event with the new status as parameter
Calls handler immediately with the last payload of the event.
off()
Accepts a handler to unregister from the specified event.
Removes all handlers for the specified event.
New Components
<ClerkFailed/>
<ClerkDegraded/>
Clerk.status values
Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change