@clerk/upgrade 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/dist/guide-generators/core-2/backend/__output.mdx +687 -0
  2. package/dist/guide-generators/core-2/chrome-extension/__output.mdx +530 -0
  3. package/dist/guide-generators/core-2/expo/__output.mdx +546 -0
  4. package/dist/guide-generators/core-2/fastify/__output.mdx +448 -0
  5. package/dist/guide-generators/core-2/gatsby/__output.mdx +503 -0
  6. package/dist/guide-generators/core-2/js/__output.mdx +628 -0
  7. package/dist/guide-generators/core-2/nextjs/__output.mdx +1169 -0
  8. package/dist/guide-generators/core-2/node/__output.mdx +592 -0
  9. package/dist/guide-generators/core-2/overview/__output.mdx +33 -0
  10. package/dist/guide-generators/core-2/overview/intro.mdx +1 -1
  11. package/dist/guide-generators/core-2/react/__output.mdx +790 -0
  12. package/dist/guide-generators/core-2/remix/__output.mdx +432 -0
  13. package/dist/guide-generators/core-2/retheme/__output.mdx +440 -0
  14. package/dist/guide-generators/core-2/shared/prepare.mdx +0 -5
  15. package/dist/guide-generators/core-2/shared/update-version.mdx +5 -5
  16. package/dist/versions/core-2/backend/members-count.md +2 -2
  17. package/dist/versions/core-2/index.js +1 -1
  18. package/dist/versions/core-2/nextjs/auth-middleware-deprecated.md +2 -2
  19. package/dist/versions/core-2/nextjs/authmiddleware-import-change.md +1 -1
  20. package/dist/versions/core-2/nextjs/with-clerk-middleware-removed.md +1 -1
  21. package/dist/versions/core-2/node/createclerkexpressrequireauth-public-key-required.md +2 -2
  22. package/dist/versions/core-2/node/createclerkexpresswithauth-publickey-required.md +7 -0
  23. package/package.json +1 -1
  24. /package/dist/versions/core-2/{js/supported-external-accounts-type-removed.md → common/supported-external-accounts-removed.md} +0 -0
@@ -0,0 +1,790 @@
1
+ ---
2
+ title: "Upgrading React to Core 2"
3
+ description: "Learn how to upgrade Clerk's React SDK to the latest version."
4
+ ---
5
+
6
+ {/* WARNING: This is a generated file and should not be edited directly. To update its contents, see the "upgrade" package in the clerk/javascript repo. */}
7
+
8
+ # Upgrading `@clerk/clerk-react` to Core 2
9
+
10
+ Core 2 is included in the React SDK starting with version 5. This new version ships with an improved design and UX for its built-in components, no "flash of white page" when authenticating, and a variety of smaller DX improvements and housekeeping items. Each of the potentially breaking changes are detailed in this guide, below.
11
+
12
+ By the end of this guide, you’ll have successfully upgraded your React project to use `@clerk/clerk-react` v5. You’ll learn how to update your dependencies, resolve breaking changes, and find deprecations. Step-by-step instructions will lead you through the process.
13
+
14
+ ## Preparing to upgrade
15
+
16
+ Before uprading, it's highly recommended that you update your Clerk SDKs to the latest Core 1 version (`npm i @clerk/clerk-react@4`). Some changes required for Core 2 SDKs can be applied incrementally to the v5 release, which should contribute to a smoother upgrading experience. After updating, look out for deprecation messages in your terminal and browser console. By resolving these deprecations you'll be able to skip many breaking changes from Core 2.
17
+
18
+ Additionally, some of the minumum version requirements for some base dependencies have been updated such that versions that are no longer supported or are at end-of-life are no longer guaranteed to work correctly with Clerk.
19
+
20
+ **Updating Node.js**
21
+
22
+ You need to have Node.js `18.17.0` or later installed. Last year, Node.js 16 entered EOL (End of life) status, so support for this version has been removed across Clerk SDKs. You can check your Node.js version by running `node -v` in your terminal. Learn more about how to [update and install Node.js](https://nodejs.org/en/learn/getting-started/how-to-install-nodejs).
23
+
24
+ **Updating React**
25
+
26
+ All react-dependent Clerk SDKs now require you to use React 18 or higher. You can update your project by installing the latest version of `react` and `react-dom`.
27
+
28
+ <CodeBlockTabs type="installer" options={["npm", "yarn", "pnpm"]}>
29
+ ```bash filename="terminal"
30
+ npm install react@latest react-dom@latest
31
+ ```
32
+
33
+ ```bash filename="terminal"
34
+ yarn add react@latest react-dom@latest
35
+ ```
36
+
37
+ ```bash filename="terminal"
38
+ pnpm add react@latest react-dom@latest
39
+ ```
40
+
41
+ </CodeBlockTabs>
42
+
43
+ If you are upgrading from React 17 or lower, make sure to [learn about how to upgrade your React version to 18](https://react.dev/blog/2022/03/08/react-18-upgrade-guide) as well.
44
+
45
+ ## Updating to Core 2
46
+
47
+ Whenever you feel ready, go ahead and install the latest version of any Clerk SDKs you are using. Make sure that you are prepared to patch some breaking changes before your app will work properly, however. The commands below demonstrate how to install the latest version.
48
+
49
+ <CodeBlockTabs type="installer" options={["npm", "yarn", "pnpm"]}>
50
+ ```bash filename="terminal"
51
+ npm install @clerk/clerk-react
52
+ ```
53
+
54
+ ```bash filename="terminal"
55
+ yarn add @clerk/clerk-react
56
+ ```
57
+
58
+ ```bash filename="terminal"
59
+ pnpm add @clerk/clerk-react
60
+ ```
61
+
62
+ </CodeBlockTabs>
63
+
64
+ ## CLI upgrade helper
65
+
66
+ Clerk now provides a `@clerk/upgrade` CLI tool that you can use to ease the upgrade process. The tool will scan your codebase and produce a list of changes you'll need to apply to your project. It should catch the vast majority of the changes needed for a successful upgrade to any SDK including Core 2. This can save you a lot of time reading through changes that don't apply to your project.
67
+
68
+ To run the CLI tool, navigate to your project and run it in the terminal:
69
+
70
+ <CodeBlockTabs type="installer" options={["npm", "yarn", "pnpm"]}>
71
+ ```bash filename="terminal"
72
+ npx @clerk/upgrade
73
+ ```
74
+
75
+ ```bash filename="terminal"
76
+ yarn dlx @clerk/upgrade
77
+ ```
78
+
79
+ ```bash filename="terminal"
80
+ pnpm dlx @clerk/upgrade
81
+ ```
82
+
83
+ </CodeBlockTabs>
84
+
85
+ If you are having trouble with `npx`, it's also possible to install directly with `npm i @clerk/upgrade -g`, and can then be run with the `clerk-upgrade` command.
86
+
87
+ ## Breaking Changes
88
+
89
+ ### Component design adjustments
90
+
91
+ The new version ships with improved design and UX across all of Clerk's [UI components](/docs/components/overview). If you have used the [`appearance` prop](/docs/components/customization/overview) or tokens for a [custom theme](/docs/components/customization/overview#create-a-custom-theme), you will likely need to make some adjustments to ensure your styling is still looking great. If you're using the [localization prop](/docs/components/customization/localization) you will likely need to make adjustments to account for added or removed localization keys.
92
+
93
+ [More detail on these changes &raquo;](component-redesign)
94
+
95
+ ### After sign up/in/out default value change
96
+
97
+ Defining redirect URLs for after sign up, in, and/or out via the Clerk dashboard has been removed in Core 2. In your Clerk dashboard, under "paths", there is a section called "Component paths", where URLs could be defined that had a deprecation warning. In Core 2, this functionality has been removed, and specifying redirect paths via the dashboard will no longer work. If you need to pass a redirect URL for after sign in/up/out, there are [a few different ways this can be done](https://clerk.com/docs/account-portal/custom-redirects), from environment variables to middleware to supplying them directly to the relevant components.
98
+
99
+ As part of this change, the default URL for each of these props has been set to `/`, so if you are passing `/` explicitly to any one of the above props, that line is no longer necessary and can be removed.
100
+
101
+ ```diff
102
+ - <UserButton afterSignOutUrl='/' />
103
+ + <UserButton />
104
+ ```
105
+
106
+ ### `afterSignXUrl` changes
107
+
108
+ Some changes are being made to the way that "after sign up/in url"s and redirect url props are handled as part of this new version, in order to make behavior more clear and predictable.
109
+
110
+ > We will refer to these urls as `afterSignXUrl` where `X` could be `Up` or `In` depending on the context.
111
+
112
+ Previously, setting `afterSignInUrl` or `afterSignOutUrl` would only actually redirect some of the time. If the user clicks on any form of link that takes them to a sign up/in page, Clerk automatically sets `redirect_url` in the querystring such that after the sign up or in, the user is returned back to the page they were on before. This is a common pattern for sign up/in flows, as it leads to the least interruption of the user's navigation through your app. When a `redirect_url` is present, any value passed to `afterSignInUrl` or `afterSignUpUrl` is ignored. However, if the user navigates directly to a sign up/in page, there’s no redirect url in the querystring and in this case the `afterSignInUrl` or `afterSignOutUrl` would take effect. This behavior was not intuitive and didn't give a way to force a redirect after sign up/in, so the behavior is changing to address both of these issues.
113
+
114
+ All `afterSignXUrl` props and `CLERK_AFTER_SIGN_X_URL` environment variables have been removed, and should be replaced by one of the following options:
115
+
116
+ - `signXForceRedirectUrl` / `CLERK_SIGN_X_FORCE_REDIRECT_URL` - if set, Clerk will always redirect to provided URL, regardless of what page the user was on before. Use this option with caution, as it will interrupt the user’s flow by taking them away from the page they were on before.
117
+ - `signXFallbackRedirectUrl` / `CLERK_SIGN_UP_FALLBACK_REDIRECT_URL` - if set, this will mirror the previous behavior, only redirecting to the provided URL if there is no `redirect_url` in the querystring.
118
+
119
+ If neither value is set, Clerk will redirect to the `redirect_url` if present, otherwise it will redirect to `/`. If you'd like to retain the current behavior of your app without any changes, you can switch `afterSignXUrl` with `signXFallbackRedirectUrl` as such:
120
+
121
+ ```diff
122
+ - <SignIn afterSignInUrl='/foo' />
123
+ + <SignIn signInFallbackRedirectUrl='/foo' />
124
+ ```
125
+
126
+ ### `navigate` prop to `ClerkProvider` replaced by `routerPush` and `routerReplace`
127
+
128
+ The `navigate` prop on ClerkProvider allowed developers to override the default navigation behavior with a custom function. However, navigate was only able to push, not replace routes. We have now added the capability for the router to push or replace, and as such, upgraded the provider prop so that it can handle either depending on the circumstance.
129
+
130
+ Two new props have been added to `ClerkProvider` that replace the single `navigate` prop, and can be used to override the default navigation behavior for either a push or replace navigation. For more information on what push and replace mean in relation to the browser history api, [check out these wonderful MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/History_API/Working_with_the_History_API).
131
+
132
+ If you’d like to keep the same behavior as you had with the single `navigate` prop, pass the exact same function to both `routerPush` and `routerReplace` and the behavior will be identical. For example:
133
+
134
+ ```diff
135
+ - <ClerkProvider navigate={ x => x } />
136
+ + <ClerkProvider routerPush={ x => x } routerReplace={ x => x } />
137
+ ```
138
+
139
+ However, you now have the option to differentiate behavior based on whether the navigation will be a push or replace.
140
+
141
+ ### Removed: `orgs` claim on JWT
142
+
143
+ In the previous version of Clerk's SDKs, if you decode the session token that Clerk returns from the server, you'll currently find an `orgs` claim on it. It lists all the orgs associated with the given user. Now, Clerk returns the `org_id`, `org_slug`, and `org_role` of the **active** organization.
144
+
145
+ The `orgs` claim was part of the `JwtPayload`. Here are a few examples of where the `JwtPayload` could be found.
146
+
147
+ <Accordion titles={["Next.js", "Fastify", "@clerk/backend", "@clerk/clerk-sdk-node"]} heading="h5">
148
+ <AccordionPanel>
149
+ ```typescript filename="Next.js"
150
+ import { getAuth } from "@clerk/nextjs/server"
151
+ const claims: JwtPayload = getAuth(request).sessionClaims
152
+
153
+ import { getAuth } from "@clerk/ssr.server"
154
+ const claims: JwtPayload = (await getAuth(request)).sessionClaims
155
+ ```
156
+
157
+ </AccordionPanel>
158
+ <AccordionPanel>
159
+ ```typescript filename="Fastify"
160
+ import { getAuth } from "@clerk/fastify"
161
+ const claims: JwtPayload = (await getAuth(request)).sessionClaims
162
+ ```
163
+ </AccordionPanel>
164
+ <AccordionPanel>
165
+ ```typescript filename="@clerk/backend"
166
+ import { createClerkClient } from "@clerk/backend"
167
+
168
+ const clerkClient = createClerkClient({ secretKey: "" })
169
+ const requestState = await clerkClient.authenticateRequest(
170
+ request,
171
+ { publishableKey: "" }
172
+ )
173
+ const claims: JwtPayload = requestState.toAuth().sessionClaims
174
+ ```
175
+
176
+ </AccordionPanel>
177
+ <AccordionPanel>
178
+ ```typescript filename="@clerk/clerk-sdk-node"
179
+ import { clerkClient } from "@clerk/clerk-sdk-node"
180
+
181
+ router.use((...args) => clerkClient.expressRequireAuth()(...args))
182
+ router.get("/me", async (req, reply: Response) => {
183
+ return reply.json({ auth: req.auth })
184
+ })
185
+ ```
186
+
187
+ </AccordionPanel>
188
+ </Accordion>
189
+
190
+ If you would like to have your JWT return all of the user's organizations, you can create a [custom JWT template](/docs/backend-requests/making/jwt-templates) in your dashboard. Add `{ "orgs": "user.organizations" }` to it.
191
+
192
+ ### Path routing is now the default
193
+
194
+ On components like [`<SignIn />`](/docs/components/authentication/sign-in) you can define the props `routing` and `path`. `routing` can be set to `'hash' | 'path' | 'virtual'` and describes the routing strategy that should be used. `path` defines where the component is mounted when `routing="path"` is used.
195
+
196
+ In the latest version, the **default** `routing` strategy has become `'path'`. Unless you change the `routing` prop, you'll need to define the `path` prop. The affected components are:
197
+
198
+ - `<SignIn />`
199
+ - `<SignUp />`
200
+ - `<UserProfile />`
201
+ - `<CreateOrganization />`
202
+ - `<OrganizationProfile />`
203
+
204
+ Here's how you'd use the components going forward:
205
+
206
+ ```jsx
207
+ <SignIn path="/sign-in" />
208
+ <SignUp path="/sign-up" />
209
+ <UserProfile path="/user-profile" />
210
+ <CreateOrganization path="/create-org" />
211
+ <OrganizationProfile path="/org-profile" />
212
+ ```
213
+
214
+ If you don't define the `path` prop an error will be thrown. Of course, you can still use `routing="hash"` or `routing="virtual"`.
215
+
216
+ ```jsx
217
+ <UserProfile routing="hash" />
218
+ <OrganizationProfile routing="virtual" />
219
+ ```
220
+
221
+
222
+
223
+ ### Image URL Name Consolidation
224
+
225
+ There are a number of Clerk primitives that contain images, and previously they each had different property names, like `avatarUrl`, `logoUrl`, `profileImageUrl`, etc. In order to promote consistency and make it simpler for developers to know where to find associated images, all image properties are now named `imageUrl`. See the list below for all affected classes:
226
+
227
+ <Accordion titles={["<code>Organization.logoUrl</code> -&gt; <code>Organization.imageUrl</code>", "<code>User.profileImageUrl</code> -&gt; <code>.imageUrl</code>", "<code>ExternalAccount.avatarUrl</code> -&gt; <code>.imageUrl</code>", "<code>OrganizationMembershipPublicUserData.profileImageUrl</code> -&gt; <code>.imageUrl</code>"]}>
228
+ <AccordionPanel>
229
+ The `logoUrl` property of any [`Organization` object](https://clerk.com/docs/references/javascript/organization/organization#organization) has been changed to `imageUrl`.
230
+ </AccordionPanel>
231
+ <AccordionPanel>
232
+ The `profileImageUrl` property of any `User` object has been changed to `imageUrl`.
233
+ </AccordionPanel>
234
+ <AccordionPanel>
235
+ The `avatarUrl` property of any [`ExternalAcccount` object](https://clerk.com/docs/references/javascript/external-account) has been changed to `imageUrl`.
236
+ </AccordionPanel>
237
+ <AccordionPanel>
238
+ The `profileImageUrl` property of any `OrganizationMembershipPublicUserData` object has been changed to `imageUrl`.
239
+ </AccordionPanel>
240
+ </Accordion>
241
+
242
+ ### Deprecation removals & housekeeping
243
+
244
+ As part of this major version, a number of previously deprecated props, arugments, methods, etc. have been removed. Additionally there have been some changes to things that are only used internally, or only used very rarely. It's highly unlikely that any given app will encounter any of these items, but they are all breaking changes, so they have all been documented below.
245
+
246
+ <Callout type='info'>
247
+ For this section more than any other one, please use the CLI upgrade tool (`npx @clerk/upgrade`). Changes in this
248
+ section are very unlikely to appear in your codebase, the tool will save time looking for them.
249
+ </Callout>
250
+
251
+ #### Deprecation removals
252
+
253
+ <Accordion titles={["<code>User.update({ password: &#39;x&#39; })</code> -&gt; <code>User.updatePassword(&#39;x&#39;)</code>", "<code>frontendApi</code> -&gt; <code>publishableKey</code> as prop to <code>ClerkProvider</code>", "<code>afterSwitchOrganizationUrl</code> -&gt; <code>afterSelectOrganizationUrl</code> in <code>OrganizationSwitcher</code>", "<code>ClerkProviderOptionsWrapper</code> type removed"]}>
254
+ <AccordionPanel>
255
+ If you are updating a user's password via the [`User.update` method](https://clerk.com/docs/references/javascript/user/user#update), it must be changed to [`User.updatePassword`](https://clerk.com/docs/references/javascript/user/password-management#update-password) instead. This method will require the current password as well as the desired new password. We made this update to improve the security of password changes. Example below:
256
+
257
+ ```diff
258
+ - user.update({ password: 'foo' });
259
+
260
+ + user.updatePassword({
261
+ + currentPassword: 'bar',
262
+ + newPassword: 'foo',
263
+ + signOutOfOtherSessions: true,
264
+ + });
265
+ ```
266
+ </AccordionPanel>
267
+ <AccordionPanel>
268
+ The `frontendApi` prop passed to `<ClerkProvider>` was renamed to `publishableKey`. **Note:** The values are different, so this is not just a key replacement. You can visit your [Clerk dashboard](https://dashboard.clerk.com/last-active?path=api-keys) to copy/paste the new keys after choosing your framework. Make sure to update this in all environments (e.g. dev, staging, production). [More information](/docs/deployments/overview#api-keys-and-environment-variables).
269
+ </AccordionPanel>
270
+ <AccordionPanel>
271
+ The `afterSwitchOrganizationUrl` prop on the `<OrganizationSwitcher />` component has been renamed to `afterSelectOrganizationUrl`. This is a quick and simple rename.
272
+
273
+ ```diff
274
+ - <OrganizationSwitcher afterSwitchOrganizationUrl='...' />
275
+ + <OrganizationSwitcher afterSelectOrganizationUrl='...' />
276
+ ```
277
+ </AccordionPanel>
278
+ <AccordionPanel>
279
+ This type was extending `ClerkProviderProps` with but was not necessary. This type is typically used internally and is not required to be imported and used directly. If needed, import and use `ClerkProviderProps` instead.
280
+ </AccordionPanel>
281
+ </Accordion>
282
+
283
+ #### Other Breaking changes
284
+
285
+ <Accordion titles={["<code>Organization.getRoles</code> arguments changed", "<code>Organization.getMemberships</code> arguments changed", "<code>Organization.getDomains</code> arguments changed", "<code>Organization.getInvitations</code> arguments changed", "<code>Organization.getMembershipRequests</code> arguments changed", "<code>User.getOrganizationInvitations</code> arguments changed", "<code>User.getOrganizationSuggestions</code> arguments changed", "<code>User.getOrganizationMemberships</code> arguments changed", "<code>Users.getOrganizationMembershipList</code> return signature changed", "<code>Users.getOrganizationInvitationList</code> return signature changed", "<code>Organizations.getOrganizationInvitationList</code> return type changed", "<code>User.getOrganizationMembershipList</code> return type changed", "<code>Users.getOrganizationList</code> return signature changed", "<code>Organization.getOrganizationList</code> return type changed", "<code>Invitations.getInvitationList</code> return signature changed", "<code>Sessions.getSessionList</code> return signature changed", "<code>Users.getUserList</code> return signature changed", "<code>AllowlistIdentifiers.getAllowlistIdentifierList</code> return signature changed", "<code>Clients.getClientList</code> return signature changed", "<code>RedirectUrls.getRedirectUrlList</code> return signature changed", "<code>Users.getUserOauthAccessToken</code> return signature changed", "<code>MagicLinkErrorCode</code> -&gt; <code>EmailLinkErrorCode</code>", "<code>useMagicLink</code> -&gt; <code>useEmailLink</code>", "<code>isMagicLinkError</code> -&gt; <code>isEmailLinkError</code>", "<code>MagicLinkError</code> -&gt; <code>EmailLinkError</code>", "<code>handleMagicLinkVerification</code> -&gt; <code>handleEmailLinkVerification</code>", "<code>invitationList</code> -&gt; <code>invitations</code> as param to <code>useOrganizations</code>", "<code>membershipList</code> -&gt; <code>members</code> as param to <code>useOrganization</code>", "<code>useOrganizations</code> -&gt; <code>useOrganizationList</code>", "<code>userProfile</code> -&gt; <code>userProfileProps</code> for <code>UserButton</code>", "<code>WithSession</code> component removed", "<code>WithClerk</code> component removed", "<code>WithUser</code> component removed", "<code>withClerk</code> function removed", "<code>withSession</code> function removed", "<code>withUser</code> function removed", "<code>MultisessionAppSupport</code> import moved to <code>/internal</code>", "Replace <code>signOutCallback</code> prop on <code>SignOutButton</code> with <code>redirectUrl</code>", "<code>setSession</code> -&gt; <code>setActive</code>", "<code>Organization.create(&#39;x&#39;)</code> -&gt; <code>Organization.create({ name: &#39;x&#39; })</code>", "<code>Organization.getPendingInvitations()</code> -&gt; <code>Organization.getInvitations({ status: &#39;pending&#39; })</code>"]}>
286
+ <AccordionPanel>
287
+ There have been a couple changes to the pagination arguments that can be passed into this function - `limit` has been renamed to `pageSize`, and `offset` has been renamed to `initialPage`. This will help to make it more clear and simple to reason about pagination control. Example of how changes might look below:
288
+
289
+ ```diff
290
+ const { data } = await organization.getRoles({
291
+ - limit: 10,
292
+ + pageSize: 10,
293
+ - offset: 10,
294
+ + initialPage: 2,
295
+ })
296
+ ```
297
+ </AccordionPanel>
298
+ <AccordionPanel>
299
+ There have been a couple changes to the pagination arguments that can be passed into this function - `limit` has been renamed to `pageSize`, and `offset` has been renamed to `initialPage`. This will help to make it more clear and simple to reason about pagination control. Example of how changes might look below:
300
+
301
+ ```diff
302
+ const { data } = await organization.getMemberships({
303
+ - limit: 10,
304
+ + pageSize: 10,
305
+ - offset: 10,
306
+ + initialPage: 2,
307
+ })
308
+ ```
309
+ </AccordionPanel>
310
+ <AccordionPanel>
311
+ There have been a couple changes to the pagination arguments that can be passed into this function - `limit` has been renamed to `pageSize`, and `offset` has been renamed to `initialPage`. This will help to make it more clear and simple to reason about pagination control. Example of how changes might look below:
312
+
313
+ ```diff
314
+ const { data } = await organization.getDomains({
315
+ - limit: 10,
316
+ + pageSize: 10,
317
+ - offset: 10,
318
+ + initialPage: 2,
319
+ })
320
+ ```
321
+ </AccordionPanel>
322
+ <AccordionPanel>
323
+ There have been a couple changes to the pagination arguments that can be passed into this function - `limit` has been renamed to `pageSize`, and `offset` has been renamed to `initialPage`. This will help to make it more clear and simple to reason about pagination control. Example of how changes might look below:
324
+
325
+ ```diff
326
+ const { data } = await organization.getInvitations({
327
+ - limit: 10,
328
+ + pageSize: 10,
329
+ - offset: 10,
330
+ + initialPage: 2,
331
+ })
332
+ ```
333
+ </AccordionPanel>
334
+ <AccordionPanel>
335
+ There have been a couple changes to the pagination arguments that can be passed into this function - `limit` has been renamed to `pageSize`, and `offset` has been renamed to `initialPage`. This will help to make it more clear and simple to reason about pagination control. Example of how changes might look below:
336
+
337
+ ```diff
338
+ const { data } = await organization.getMembershipRequests({
339
+ - limit: 10,
340
+ + pageSize: 10,
341
+ - offset: 10,
342
+ + initialPage: 2,
343
+ })
344
+ ```
345
+ </AccordionPanel>
346
+ <AccordionPanel>
347
+ There have been a couple changes to the pagination arguments that can be passed into this function - `limit` has been renamed to `pageSize`, and `offset` has been renamed to `initialPage`. This will help to make it more clear and simple to reason about pagination control. Example of how changes might look below:
348
+
349
+ ```diff
350
+ const { data } = await user.getOrganizationInvitations({
351
+ - limit: 10,
352
+ + pageSize: 10,
353
+ - offset: 10,
354
+ + initialPage: 2,
355
+ })
356
+ ```
357
+ </AccordionPanel>
358
+ <AccordionPanel>
359
+ There have been a couple changes to the pagination arguments that can be passed into this function - `limit` has been renamed to `pageSize`, and `offset` has been renamed to `initialPage`. This will help to make it more clear and simple to reason about pagination control. Example of how changes might look below:
360
+
361
+ ```diff
362
+ const { data } = await user.getOrganizationSuggestions({
363
+ - limit: 10,
364
+ + pageSize: 10,
365
+ - offset: 10,
366
+ + initialPage: 2,
367
+ })
368
+ ```
369
+ </AccordionPanel>
370
+ <AccordionPanel>
371
+ There have been a couple changes to the pagination arguments that can be passed into this function - `limit` has been renamed to `pageSize`, and `offset` has been renamed to `initialPage`. This will help to make it more clear and simple to reason about pagination control. Example of how changes might look below:
372
+
373
+ ```diff
374
+ const { data } = await user.getOrganizationMemberships({
375
+ - limit: 10,
376
+ + pageSize: 10,
377
+ - offset: 10,
378
+ + initialPage: 2,
379
+ })
380
+ ```
381
+ </AccordionPanel>
382
+ <AccordionPanel>
383
+ The response payload of `Users.getOrganizationMembershipList` was changed as part of the core 2 release. Rather than directly returning ` data`, the return signature is now `{ data, totalCount }`. Since backend API responses are paginated, the `totalCount` property is helpful in determining the total number of items in the response easily, and this change in the backend SDK aligns the response shape with what the backend API returns directly.
384
+
385
+ Here's an example of how the response shape would change with this modification:
386
+
387
+ ```diff
388
+ - const data = await clerkClient.users.getOrganizationMembershipList()
389
+ + const { data, totalCount } = await clerkClient.users.getOrganizationMembershipList()
390
+ ```
391
+ </AccordionPanel>
392
+ <AccordionPanel>
393
+ The response payload of `Users.getOrganizationInvitationList` was changed as part of the core 2 release. Rather than directly returning ` data`, the return signature is now `{ data, totalCount }`. Since backend API responses are paginated, the `totalCount` property is helpful in determining the total number of items in the response easily, and this change in the backend SDK aligns the response shape with what the backend API returns directly.
394
+
395
+ Here's an example of how the response shape would change with this modification:
396
+
397
+ ```diff
398
+ - const data = await clerkClient.users.getOrganizationInvitationList()
399
+ + const { data, totalCount } = await clerkClient.users.getOrganizationInvitationList()
400
+ ```
401
+ </AccordionPanel>
402
+ <AccordionPanel>
403
+ The return type for this function was previously `[Items]` but has now been updated to `{ data: [Items], totalCount: number }`. Since Clerk's API responses are paginated, the `totalCount` property is helpful in determining the total number of items in the response easily. A before/after code example can be seen below:
404
+
405
+ ```diff
406
+ const data = await clerkClient.organizations.getOrganizationInvitationList({
407
+ organizationId: "...",
408
+ })
409
+
410
+ - data.forEach(() => {})
411
+ + data.data.forEach(() => {})
412
+ ```
413
+ </AccordionPanel>
414
+ <AccordionPanel>
415
+ The return type for this function was previously `[Items]` but has now been updated to `{ data: [Items], totalCount: number }`. Since Clerk's API responses are paginated, the `totalCount` property is helpful in determining the total number of items in the response easily. A before/after code example can be seen below:
416
+
417
+ ```diff
418
+ const { user } = useUser()
419
+ const membershipList = user.getOrganizationMembershipList()
420
+
421
+ - membershipList.forEach(() => {})
422
+ + membershipList.data.forEach(() => {})
423
+ ```
424
+ </AccordionPanel>
425
+ <AccordionPanel>
426
+ The response payload of `Users.getOrganizationList` was changed as part of the core 2 release. Rather than directly returning ` data`, the return signature is now `{ data, totalCount }`. Since backend API responses are paginated, the `totalCount` property is helpful in determining the total number of items in the response easily, and this change in the backend SDK aligns the response shape with what the backend API returns directly.
427
+
428
+ Here's an example of how the response shape would change with this modification:
429
+
430
+ ```diff
431
+ - const data = await clerkClient.users.getOrganizationList()
432
+ + const { data, totalCount } = await clerkClient.users.getOrganizationList()
433
+ ```
434
+ </AccordionPanel>
435
+ <AccordionPanel>
436
+ The return type for this function was previously `[Items]` but has now been updated to `{ data: [Items], totalCount: number }`. Since Clerk's API responses are paginated, the `totalCount` property is helpful in determining the total number of items in the response easily. A before/after code example can be seen below:
437
+
438
+ ```diff
439
+ const { organization } = useOrganization()
440
+ const orgList = organization.getOrganizationList()
441
+
442
+ - orgList.forEach(() => {})
443
+ + orgList.data.forEach(() => {})
444
+ ```
445
+ </AccordionPanel>
446
+ <AccordionPanel>
447
+ The response payload of `Invitations.getInvitationList` was changed as part of the core 2 release. Rather than directly returning ` data`, the return signature is now `{ data, totalCount }`. Since backend API responses are paginated, the `totalCount` property is helpful in determining the total number of items in the response easily, and this change in the backend SDK aligns the response shape with what the backend API returns directly.
448
+
449
+ Here's an example of how the response shape would change with this modification:
450
+
451
+ ```diff
452
+ - const data = await clerkClient.invitations.getInvitationList()
453
+ + const { data, totalCount } = await clerkClient.invitations.getInvitationList()
454
+ ```
455
+ </AccordionPanel>
456
+ <AccordionPanel>
457
+ The response payload of `Sessions.getSessionList` was changed as part of the core 2 release. Rather than directly returning ` data`, the return signature is now `{ data, totalCount }`. Since backend API responses are paginated, the `totalCount` property is helpful in determining the total number of items in the response easily, and this change in the backend SDK aligns the response shape with what the backend API returns directly.
458
+
459
+ Here's an example of how the response shape would change with this modification:
460
+
461
+ ```diff
462
+ - const data = await clerkClient.sessions.getSessionList()
463
+ + const { data, totalCount } = await clerkClient.sessions.getSessionList()
464
+ ```
465
+ </AccordionPanel>
466
+ <AccordionPanel>
467
+ The response payload of `Users.getUserList` was changed as part of the core 2 release. Rather than directly returning ` data`, the return signature is now `{ data, totalCount }`. Since backend API responses are paginated, the `totalCount` property is helpful in determining the total number of items in the response easily, and this change in the backend SDK aligns the response shape with what the backend API returns directly.
468
+
469
+ Here's an example of how the response shape would change with this modification:
470
+
471
+ ```diff
472
+ - const data = await clerkClient.users.getUserList()
473
+ + const { data, totalCount } = await clerkClient.users.getUserList()
474
+ ```
475
+ </AccordionPanel>
476
+ <AccordionPanel>
477
+ The response payload of `AllowlistIdentifiers.getAllowlistIdentifierList` was changed as part of the core 2 release. Rather than directly returning ` data`, the return signature is now `{ data, totalCount }`. Since backend API responses are paginated, the `totalCount` property is helpful in determining the total number of items in the response easily, and this change in the backend SDK aligns the response shape with what the backend API returns directly.
478
+
479
+ Here's an example of how the response shape would change with this modification:
480
+
481
+ ```diff
482
+ - const data = await clerkClient.allowlistIdentifiers.getAllowlistIdentifierList()
483
+ + const { data, totalCount } = await clerkClient.allowlistIdentifiers.getAllowlistIdentifierList()
484
+ ```
485
+ </AccordionPanel>
486
+ <AccordionPanel>
487
+ The response payload of `Clients.getClientList` was changed as part of the core 2 release. Rather than directly returning ` data`, the return signature is now `{ data, totalCount }`. Since backend API responses are paginated, the `totalCount` property is helpful in determining the total number of items in the response easily, and this change in the backend SDK aligns the response shape with what the backend API returns directly.
488
+
489
+ Here's an example of how the response shape would change with this modification:
490
+
491
+ ```diff
492
+ - const data = await clerkClient.clients.getClientList()
493
+ + const { data, totalCount } = await clerkClient.allowlistIdentifiers.getClientList()
494
+ ```
495
+ </AccordionPanel>
496
+ <AccordionPanel>
497
+ The response payload of `RedirectUrls.getRedirectUrlList` was changed as part of the core 2 release. Rather than directly returning ` data`, the return signature is now `{ data, totalCount }`. Since backend API responses are paginated, the `totalCount` property is helpful in determining the total number of items in the response easily, and this change in the backend SDK aligns the response shape with what the backend API returns directly.
498
+
499
+ Here's an example of how the response shape would change with this modification:
500
+
501
+ ```diff
502
+ - const data = await clerkClient.redirectUrls.getRedirectUrlList()
503
+ + const { data, totalCount } = await clerkClient.redirectUrls.getRedirectUrlList()
504
+ ```
505
+ </AccordionPanel>
506
+ <AccordionPanel>
507
+ The response payload of `Users.getUserOauthAccessToken` was changed as part of the core 2 release. Rather than directly returning ` data`, the return signature is now `{ data, totalCount }`. Since backend API responses are paginated, the `totalCount` property is helpful in determining the total number of items in the response easily, and this change in the backend SDK aligns the response shape with what the backend API returns directly.
508
+
509
+ Here's an example of how the response shape would change with this modification:
510
+
511
+ ```diff
512
+ - const data = await clerkClient.users.getUserOauthAccessToken()
513
+ + const { data, totalCount } = await clerkClient.users.getUserOauthAccessToken()
514
+ ```
515
+ </AccordionPanel>
516
+ <AccordionPanel>
517
+ Across Clerk's documentation and codebases the term "magic link" was changed to "email link" as it more accurately reflects the functionality.
518
+ </AccordionPanel>
519
+ <AccordionPanel>
520
+ Across Clerk's documentation and codebases the term "magic link" was changed to "email link" as it more accurately reflects functionality.
521
+ </AccordionPanel>
522
+ <AccordionPanel>
523
+ Across Clerk's documentation and codebases the term "magic link" was changed to "email link" as it more accurately reflects the functionality.
524
+ </AccordionPanel>
525
+ <AccordionPanel>
526
+ Across Clerk's documentation and codebases the term "magic link" was changed to "email link" as it more accurately reflects the functionality.
527
+ </AccordionPanel>
528
+ <AccordionPanel>
529
+ Across Clerk's documentation and codebases the term "magic link" was changed to "email link" as it more accurately reflects functionality.
530
+ </AccordionPanel>
531
+ <AccordionPanel>
532
+ The `invitationList` param to the `useOrganizations` hook has been replaced by `invitations`. This param also has a slightly different way of working, examples included below. Note also that `useOrganizations` is deprecated and should be updated to `useOrganization` instead.
533
+
534
+ ```js
535
+ // before
536
+ const { invitationList } = useOrganization({
537
+ invitationList: { limit: 10, offset: 1 },
538
+ });
539
+
540
+ // after
541
+ const { invitations } = useOrganization({
542
+ invitations: {
543
+ initialPage: 1,
544
+ pageSize: 10,
545
+ },
546
+ });
547
+
548
+ // you can also simply return all invitations
549
+ const { invitations } = useOrganization({ invitations: true });
550
+ ```
551
+ </AccordionPanel>
552
+ <AccordionPanel>
553
+ The `membershipList` param from the `useOrganization` hook has been removed. Instead, [use the `memberships` param](https://clerk.com/docs/references/react/use-organization#parameters). Examples of each can be seen here:
554
+
555
+ ```js
556
+ // before
557
+ const { membershipList } = useOrganization({
558
+ membershipList: { limit: 10, offset: 1 },
559
+ });
560
+
561
+ // after
562
+ const { memberships } = useOrganization({
563
+ memberships: {
564
+ initialPage: 1,
565
+ pageSize: 10,
566
+ },
567
+ });
568
+
569
+ // you can also simply return all memberships
570
+ const { memberships } = useOrganization({ memberships: true });
571
+ ```
572
+ </AccordionPanel>
573
+ <AccordionPanel>
574
+ Any place where `useOrganizations` is used should be switched to [`useOrganizationList`](https://clerk.com/docs/references/react/use-organization-list) or [`useOrganization`](https://clerk.com/docs/references/react/use-organization) instead. The return signature has also changed, so take note of this when making the upgrade.
575
+
576
+ ```js
577
+ // before: useOrganizations return values
578
+ {
579
+ isLoaded: boolean,
580
+ createOrganization: clerk.createOrganization,
581
+ getOrganizationMemberships: clerk.getOrganizationMemberships,
582
+ getOrganization: clerk.getOrganization,
583
+ }
584
+
585
+ // after: useOrganizationList return values
586
+ {
587
+ isLoaded: boolean,
588
+ createOrganization: clerk.createOrganization,
589
+ userMemberships: PaginatedResourcesWithDefault<...> | PaginatedResources<...>,
590
+ userInvitations: PaginatedResourcesWithDefault<...> | PaginatedResources<...>,
591
+ userSuggestions: PaginatedResourcesWithDefault<...> | PaginatedResources<...>,
592
+ setActive: clerk.setActive,
593
+ }
594
+ ```
595
+ </AccordionPanel>
596
+ <AccordionPanel>
597
+ The `userProfile` prop on [the `UserButton` component](https://clerk.com/docs/references/javascript/clerk/user-button#user-button-component) has been changed to `userProfileProps`. This is purely a name change, none of the values need to be updated.
598
+
599
+ ```diff
600
+ - <UserButton userProfile={} />
601
+ + <UserButton userProfileProps={} />
602
+ ```
603
+ </AccordionPanel>
604
+ <AccordionPanel>
605
+ The `WithSession` higher order component has been removed. If you would still like to use this function in the way its implemented, it can be created quickly using Clerk's [custom hooks](https://clerk.com/docs/references/react/overview). An example of how to do so is below:
606
+
607
+ ```js
608
+ export const WithSession = ({ children }) => {
609
+ const session = useSession();
610
+ if (typeof children !== 'function') throw new Error();
611
+
612
+ return {children(session)};
613
+ };
614
+ ```
615
+ </AccordionPanel>
616
+ <AccordionPanel>
617
+ The `WithClerk` higher order component has been removed. If you would still like to use this function in the way its implemented, it can be created quickly using Clerk's [custom hooks](https://clerk.com/docs/references/react/overview). An example of how to do so is below:
618
+
619
+ ```js
620
+ export const WithClerk = ({ children }) => {
621
+ const clerk = useClerk();
622
+ if (typeof children !== 'function') throw new Error();
623
+
624
+ return {children(clerk)};
625
+ };
626
+ ```
627
+ </AccordionPanel>
628
+ <AccordionPanel>
629
+ The `WithUser` higher order component has been removed. If you would still like to use this function in the way its implemented, it can be created quickly using Clerk's [custom hooks](https://clerk.com/docs/references/react/overview). An example of how to do so is below:
630
+
631
+ ```js
632
+ export const WithUser = ({ children }) => {
633
+ const user = useUser();
634
+ if (typeof children !== 'function') throw new Error();
635
+
636
+ return {children(user)};
637
+ };
638
+ ```
639
+ </AccordionPanel>
640
+ <AccordionPanel>
641
+ The `withClerk` higher order function has been removed. If you would still like to use this function in the way its implemented, it can be created quickly using Clerk's [custom hooks](https://clerk.com/docs/references/react/overview). An example of how to do so is below:
642
+
643
+ ```js
644
+ function withClerk(Component, displayName) {
645
+ displayName = displayName || Component.displayName || Component.name || 'Component';
646
+ Component.displayName = displayName;
647
+ const HOC = props => {
648
+ const clerk = useIsomorphicClerkContext();
649
+
650
+ if (!clerk.loaded) return null;
651
+
652
+ return (
653
+ <Component
654
+ {...props}
655
+ clerk={clerk}
656
+ />
657
+ );
658
+ };
659
+
660
+ HOC.displayName = `withClerk(${displayName})`;
661
+ return HOC;
662
+ }
663
+ ```
664
+ </AccordionPanel>
665
+ <AccordionPanel>
666
+ The `withSession` higher order function has been removed. If you would still like to use this function in the way its implemented, it can be created quickly using Clerk's [custom hooks](https://clerk.com/docs/references/react/overview). An example of how to do so is below:
667
+
668
+ ```js
669
+ function withSession(Component, displayName) {
670
+ displayName = displayName || Component.displayName || Component.name || 'Component';
671
+ Component.displayName = displayName;
672
+ const HOC = props => {
673
+ const session = useSessionContext();
674
+
675
+ if (!session) return null;
676
+
677
+ return (
678
+ <Component
679
+ {...props}
680
+ session={session}
681
+ />
682
+ );
683
+ };
684
+
685
+ HOC.displayName = `withSession(${displayName})`;
686
+ return HOC;
687
+ }
688
+ ```
689
+ </AccordionPanel>
690
+ <AccordionPanel>
691
+ The `withUser` higher order function has been removed. If you would still like to use this function in the way its implemented, it can be created quickly using Clerk's [custom hooks](https://clerk.com/docs/references/react/overview). An example of how to do so is below:
692
+
693
+ ```js
694
+ function withUser(Component, displayName) {
695
+ displayName = displayName || Component.displayName || Component.name || 'Component';
696
+ Component.displayName = displayName;
697
+ const HOC = props => {
698
+ const clerk = useUserContext();
699
+
700
+ if (!user) return null;
701
+
702
+ return (
703
+ <Component
704
+ {...props}
705
+ user={user}
706
+ />
707
+ );
708
+ };
709
+
710
+ HOC.displayName = `withUser(${displayName})`;
711
+ return HOC;
712
+ }
713
+ ```
714
+ </AccordionPanel>
715
+ <AccordionPanel>
716
+ `MultiSessionAppSupport` is a component that handles the intermediate “undefined” state for multisession apps by unmounting and remounting the components during the session switch (`setActive` call) in order to solve theoretical edge-cases that can arise while switching sessions. It is undocumented and intended only for internal use, so it has been moved to an `/internal` import path. Please note that internal imports are not intended for public use, and are outside the scope of semver.
717
+
718
+ ```diff
719
+ - import { MultiSessionAppSupport } from '@clerk/clerk-react'
720
+ + import { MultiSessionAppSupport } from '@clerk/clerk-react/internal'
721
+ ```
722
+ </AccordionPanel>
723
+ <AccordionPanel>
724
+ The `signOutCallback` prop on the [`<SignOutButton />` component](https://clerk.com/docs/components/unstyled/sign-out-button) has been removed. Instead, you can use the `redirectUrl` prop. Example below:
725
+
726
+ ```diff
727
+ import { SignOutButton } from "@clerk/clerk-react";
728
+
729
+ export const Signout = () => {
730
+ return (
731
+ <SignOutButton
732
+ - signOutCallback={() => { window.location.href = "/your-path" }}
733
+ + redirectUrl="/your-path"
734
+ >
735
+ <button>Sign Out</button>
736
+ </SignOutButton>
737
+ )
738
+ }
739
+ ```
740
+ </AccordionPanel>
741
+ <AccordionPanel>
742
+ `setSession` should be replaced with `setActive`. The format of the parameters has changed slightly - `setActive` takes an object where `setSession` took params directly. The `setActive` function also can accept an `organization` param that is used to set the currently active organization. The return signature did not change. Read the [API documentation](/docs/references/javascript/clerk/session-methods#set-active) for more detail. This function should be expected to be returned from one of the following Clerk hooks: `useSessionList`, `useSignUp`, or `useSignIn`. Some migration examples:
743
+
744
+ ```diff
745
+ - await setSession('sessionID', () => void)
746
+ + await setActive({ session: 'sessionID', beforeEmit: () => void })
747
+
748
+ - await setSession(sessionObj)
749
+ + await setActive({ session: sessionObj })
750
+
751
+ - await setSession(sessionObj, () => void)
752
+ + await setActive({ session: sessionObj, beforeEmit: () => void })
753
+ ```
754
+
755
+ `setActive` also supports setting an active organization:
756
+
757
+ ```js
758
+ await setActive({
759
+ session: 'sessionID',
760
+ organization: 'orgID',
761
+ beforeEmit: () => void
762
+ })
763
+
764
+ await setActive({
765
+ session: sessionObj,
766
+ organization: orgObj,
767
+ beforeEmit: () => void
768
+ })
769
+ ```
770
+ </AccordionPanel>
771
+ <AccordionPanel>
772
+ Passing a string as an argument to `Organization.create` is no longer possible - instead, pass an object with the `name` property.
773
+
774
+ ```diff
775
+ - Organization.create('...');
776
+ + Organization.create({ name: '...' });
777
+ ```
778
+ </AccordionPanel>
779
+ <AccordionPanel>
780
+ The `Organization.getPendingInvitations()` method has been removed. You can use `Organization.getInvitations` instead.
781
+
782
+ ```diff
783
+ - Organization.getPendingInvitations();
784
+ + Organization.getInvitations({ status: 'pending' });
785
+ ```
786
+ </AccordionPanel>
787
+ </Accordion>
788
+
789
+
790
+