Skip to content

Commit 7fb6309

Browse files
brkalowalexcarpenter
authored andcommitted
feat(clerk-react): Support for fallback prop (#4723)
Co-authored-by: Alex Carpenter <[email protected]>
1 parent c4db8db commit 7fb6309

File tree

32 files changed

+768
-246
lines changed

32 files changed

+768
-246
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@clerk/clerk-react': minor
3+
---
4+
5+
Adds support for a `fallback` prop on Clerk's components. This allows rendering of a placeholder element while Clerk's components are mounting. Use this to help mitigate layout shift when using Clerk's components. Example usage:
6+
7+
8+
```tsx
9+
<SignIn fallback={<LoadingSkeleton />} />
10+
```
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { CreateOrganization } from '@clerk/nextjs';
2+
3+
export default function Page() {
4+
return (
5+
<div>
6+
<CreateOrganization fallback={<>Loading create organization</>} />
7+
</div>
8+
);
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { OrganizationList } from '@clerk/nextjs';
2+
3+
export default function Page() {
4+
return (
5+
<div>
6+
<OrganizationList fallback={<>Loading organization list</>} />
7+
</div>
8+
);
9+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { OrganizationProfile } from '@clerk/nextjs';
2+
3+
export default function Page() {
4+
return (
5+
<div>
6+
<OrganizationProfile
7+
routing='hash'
8+
fallback={<>Loading organization profile</>}
9+
/>
10+
</div>
11+
);
12+
}

integration/templates/next-app-router/src/app/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { SignedIn, SignedOut, SignIn, UserButton, Protect } from '@clerk/nextjs';
1+
import { SignedIn, SignedOut, SignIn, UserButton, Protect, OrganizationSwitcher } from '@clerk/nextjs';
22
import Link from 'next/link';
33
import { ClientId } from './client-id';
44

55
export default function Home() {
66
return (
77
<main>
8-
<UserButton />
8+
<UserButton fallback={<>Loading user button</>} />
9+
<OrganizationSwitcher fallback={<>Loading organization switcher</>} />
910
<ClientId />
1011
<SignedIn>SignedIn</SignedIn>
1112
<SignedOut>SignedOut</SignedOut>

integration/templates/next-app-router/src/app/sign-in/[[...catchall]]/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export default function Page() {
77
routing={'path'}
88
path={'/sign-in'}
99
signUpUrl={'/sign-up'}
10+
fallback={<>Loading sign in</>}
1011
__experimental={{
1112
combinedProps: {},
1213
}}

integration/templates/next-app-router/src/app/sign-up/[[...catchall]]/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export default function Page() {
77
routing={'path'}
88
path={'/sign-up'}
99
signInUrl={'/sign-in'}
10+
fallback={<>Loading sign up</>}
1011
/>
1112
</div>
1213
);
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { OrganizationSwitcher } from '@clerk/nextjs';
22

33
export default function Page() {
4-
return <OrganizationSwitcher hidePersonal={true} />;
4+
return (
5+
<OrganizationSwitcher
6+
hidePersonal={true}
7+
fallback={<>Loading organization switcher</>}
8+
/>
9+
);
510
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { UserButton } from '@clerk/nextjs';
2+
3+
export default function Page() {
4+
return (
5+
<div>
6+
<UserButton fallback={<>Loading user button</>} />
7+
</div>
8+
);
9+
}

integration/templates/next-app-router/src/app/user/[[...catchall]]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { UserProfile } from '@clerk/nextjs';
33
export default function Page() {
44
return (
55
<div>
6-
<UserProfile />
6+
<UserProfile fallback={<>Loading user profile</>} />
77
</div>
88
);
99
}

0 commit comments

Comments
 (0)