Skip to content
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

Open
wants to merge 59 commits into
base: main
Choose a base branch
from

Conversation

panteliselef
Copy link
Member

@panteliselef panteliselef commented Mar 28, 2025

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 or Clerk.load() failed
  • ready set when Clerk is fully operational
  • degraded set when Clerk is partially operational

useClerk().loaded is true when useClerk().status is either "ready" or "degraded".
useClerk().loaded is false when useClerk().status is "loading" or "error".

Important

🚨🚨 Clerk.status becomes loading upon instantiation not upon calling .load()

New APIs

const handler = (status)=> {}
window.Clerk.on('status', handler)
window.Clerk.off('status', handler)

on()

Calls handler on every status event with the new status as parameter

window.Clerk.on('status',(status)=>{})

Calls handler immediately with the last payload of the event.

window.Clerk.on('status',(status)=>{}, {notify:true})

off()

Accepts a handler to unregister from the specified event.

window.Clerk.off('status',handler)

Removes all handlers for the specified event.

window.Clerk.off('status')

New Components

<ClerkFailed/>

<ClerkLoaded>
  <MyCustomSignInForm/>
</ClerkLoaded>
<ClerkFailed>
  <ContactSupportBanner/>
</ClerkFailed>

<ClerkDegraded/>

<ClerkLoaded>
  <MyCustomPasskeyRegistration/>
  <ClerkDegraded>
    We are experiencing issues, registering a passkey might fail. 
  </ClerkDegraded>
</ClerkLoaded>

Clerk.status values

image

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Copy link

vercel bot commented Mar 28, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 10, 2025 11:38am

…clerk-has-failed-to-load-from

# Conflicts:
#	packages/react/src/isomorphicClerk.ts
Copy link

changeset-bot bot commented Mar 31, 2025

🦋 Changeset detected

Latest commit: 55da252

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 22 packages
Name Type
@clerk/nextjs Minor
@clerk/clerk-react Minor
@clerk/clerk-js Minor
@clerk/types Minor
@clerk/chrome-extension Patch
@clerk/elements Patch
@clerk/clerk-expo Patch
@clerk/react-router Patch
@clerk/remix Patch
@clerk/tanstack-react-start Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/expo-passkeys Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/localizations Patch
@clerk/nuxt Patch
@clerk/shared Patch
@clerk/testing Patch
@clerk/themes Patch
@clerk/vue Patch

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
Copy link
Member

@LekoArts LekoArts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, some smaller comments

@panteliselef panteliselef force-pushed the elef/sdki-730-introduce-way-to-determine-if-clerk-has-failed-to-load-from branch from 86733c1 to 177e4e2 Compare April 10, 2025 08:37
@LekoArts LekoArts dismissed their stale review April 10, 2025 08:43

My comments were addressed, so no reason to block this

@panteliselef panteliselef force-pushed the elef/sdki-730-introduce-way-to-determine-if-clerk-has-failed-to-load-from branch from 177e4e2 to 67fbe8f Compare April 10, 2025 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants