<ClerkLoaded>
The <ClerkLoaded>
component guarantees that the Clerk object has loaded (the status
is 'ready'
or 'degraded'
) and will be available under window.Clerk
. This allows you to wrap child components to access the Clerk
object without the need to check it exists.
Usage
It's not recommended to wrap the entire app in the <ClerkLoaded>
component; instead, only wrap the components that need access to the Clerk
object.
import { ClerkLoaded, ClerkLoading, ClerkDegraded, ClerkFailed } from '@clerk/nextjs'
declare global {
interface Window {
Clerk: any
}
}
export default function Page() {
return (
<>
<ClerkLoading>
<p>Clerk is loading...</p>
</ClerkLoading>
<ClerkLoaded>
<p>Clerk has loaded (ready or degraded)</p>
<MyCustomSignInFlow />
<ClerkDegraded>
<p>Clerk is experiencing issues. Please try again later.</p>
</ClerkDegraded>
</ClerkLoaded>
<ClerkFailed>
<p>Something went wrong with Clerk. Please contact support.</p>
</ClerkFailed>
</>
)
}
import { ClerkLoaded, ClerkLoading, ClerkDegraded, ClerkFailed } from '@clerk/nextjs'
declare global {
interface Window {
Clerk: any
}
}
export default function Page() {
return (
<>
<ClerkLoading>
<p>Clerk is loading...</p>
</ClerkLoading>
<ClerkLoaded>
<p>Clerk has loaded (ready or degraded)</p>
<MyCustomSignInFlow />
<ClerkDegraded>
<p>Clerk is experiencing issues. Please try again later.</p>
</ClerkDegraded>
</ClerkLoaded>
<ClerkFailed>
<p>Something went wrong with Clerk. Please contact support.</p>
</ClerkFailed>
</>
)
}
import { ClerkLoading, ClerkLoaded } from '@clerk/clerk-expo'
import { Text, View } from 'react-native'
declare global {
interface Window {
Clerk: any
}
}
export default function Screen() {
return (
<View>
<ClerkLoading>
<Text>Clerk is loading</Text>
</ClerkLoading>
<ClerkLoaded>
<Text>Clerk has loaded (ready or degraded)</Text>
<MyCustomSignInFlow />
</ClerkLoaded>
</View>
)
}
import { ClerkLoaded, ClerkLoading, ClerkDegraded, ClerkFailed } from '@clerk/clerk-react'
declare global {
interface Window {
Clerk: any
}
}
export default function Example() {
return (
<>
<ClerkLoading>
<p>Clerk is loading...</p>
</ClerkLoading>
<ClerkLoaded>
<p>Clerk has loaded (ready or degraded)</p>
<MyCustomSignInFlow />
<ClerkDegraded>
<p>Clerk is experiencing issues. Please try again later.</p>
</ClerkDegraded>
</ClerkLoaded>
<ClerkFailed>
<p>Something went wrong with Clerk. Please contact support.</p>
</ClerkFailed>
</>
)
}
import { ClerkLoading, ClerkLoaded, ClerkDegraded, ClerkFailed } from '@clerk/react-router'
export default function Example() {
return (
<>
<ClerkLoading>
<p>Clerk is loading...</p>
</ClerkLoading>
<ClerkLoaded>
<p>Clerk has loaded (ready or degraded)</p>
<MyCustomSignInFlow />
<ClerkDegraded>
<p>Clerk is experiencing issues. Please try again later.</p>
</ClerkDegraded>
</ClerkLoaded>
<ClerkFailed>
<p>Something went wrong with Clerk. Please contact support.</p>
</ClerkFailed>
</>
)
}
import { ClerkLoading, ClerkLoaded, ClerkDegraded, ClerkFailed } from '@clerk/remix'
declare global {
interface Window {
Clerk: any
}
}
export default function Index() {
return (
<>
<ClerkLoading>
<p>Clerk is loading...</p>
</ClerkLoading>
<ClerkLoaded>
<p>Clerk has loaded (ready or degraded)</p>
<MyCustomSignInFlow />
<ClerkDegraded>
<p>Clerk is experiencing issues. Please try again later.</p>
</ClerkDegraded>
</ClerkLoaded>
<ClerkFailed>
<p>Something went wrong with Clerk. Please contact support.</p>
</ClerkFailed>
</>
)
}
import { ClerkLoading, ClerkLoaded, ClerkDegraded, ClerkFailed } from '@clerk/tanstack-react-start'
import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/example')({
component: Example,
})
function Example() {
return (
<>
<ClerkLoading>
<p>Clerk is loading...</p>
</ClerkLoading>
<ClerkLoaded>
<p>Clerk has loaded (ready or degraded)</p>
<MyCustomSignInFlow />
<ClerkDegraded>
<p>Clerk is experiencing issues. Please try again later.</p>
</ClerkDegraded>
</ClerkLoaded>
<ClerkFailed>
<p>Something went wrong with Clerk. Please contact support.</p>
</ClerkFailed>
</>
)
}
Feedback
Last updated on