Skip to content

Commit 8c0e79d

Browse files
committed
add change file
1 parent f519941 commit 8c0e79d

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

.changeset/show-the-guards.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
'@clerk/chrome-extension': major
44
'@clerk/expo': major
55
'@clerk/nextjs': major
6+
'@clerk/nuxt': major
67
'@clerk/react': major
8+
'@clerk/react-router': major
79
'@clerk/shared': minor
10+
'@clerk/tanstack-react-start': major
811
'@clerk/vue': major
912
---
1013

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
title: '`Protect`, `SignedIn`, and `SignedOut` replaced by `Show`'
3+
matcher: '<(Protect|SignedIn|SignedOut)(\\s|>)'
4+
matcherFlags: 'm'
5+
category: 'breaking'
6+
---
7+
8+
The authorization control components `Protect`, `SignedIn`, and `SignedOut` have been removed in favor of a single component: `Show`.
9+
10+
### Signed in / signed out
11+
12+
```diff
13+
-import { SignedIn, SignedOut } from '@clerk/react';
14+
+import { Show } from '@clerk/react';
15+
16+
-<SignedIn>
17+
+<Show when="signedIn">
18+
<Dashboard />
19+
-</SignedIn>
20+
+</Show>
21+
22+
-<SignedOut>
23+
+<Show when="signedOut">
24+
<SignIn />
25+
-</SignedOut>
26+
+</Show>
27+
```
28+
29+
### Authorization checks (roles/permissions/features/plans)
30+
31+
```diff
32+
-import { Protect } from '@clerk/react';
33+
+import { Show } from '@clerk/react';
34+
35+
-<Protect role="admin" fallback={<p>Unauthorized</p>}>
36+
+<Show when={{ role: 'admin' }} fallback={<p>Unauthorized</p>}>
37+
<AdminPanel />
38+
-</Protect>
39+
+</Show>
40+
41+
-<Protect permission="org:billing:manage">
42+
+<Show when={{ permission: 'org:billing:manage' }}>
43+
<BillingSettings />
44+
-</Protect>
45+
+</Show>
46+
```
47+
48+
If you were using `condition={(has) => ...}` on `Protect`, pass that callback to `when`:
49+
50+
```diff
51+
-<Protect condition={(has) => has({ role: 'admin' }) && isAllowed}>
52+
+<Show when={(has) => has({ role: 'admin' }) && isAllowed}>
53+
<AdminPanel />
54+
-</Protect>
55+
+</Show>
56+
```
57+
58+
To auto-migrate common patterns, run the upgrade CLI (includes a `transform-protect-to-show` codemod):
59+
60+
```bash
61+
npx @clerk/upgrade --release core-3
62+
```

packages/upgrade/src/versions/core-3/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ export default {
1919
'transform-appearance-layout-to-options',
2020
'transform-themes-to-ui-themes',
2121
'transform-align-experimental-unstable-prefixes',
22+
'transform-protect-to-show',
2223
],
2324
};

0 commit comments

Comments
 (0)