@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,628 @@
1
+ ---
2
+ title: "Upgrading Javascript to Core 2"
3
+ description: "Learn how to upgrade Clerk's Javascript 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-js` to Core 2
9
+
10
+ Core 2 is included in the Javascript 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 JS project to use `@clerk/clerk-js` 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-js@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 to Core 2
21
+
22
+ 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.
23
+
24
+ <CodeBlockTabs type="installer" options={["npm", "yarn", "pnpm"]}>
25
+ ```bash filename="terminal"
26
+ npm install @clerk/clerk-js
27
+ ```
28
+
29
+ ```bash filename="terminal"
30
+ yarn add @clerk/clerk-js
31
+ ```
32
+
33
+ ```bash filename="terminal"
34
+ pnpm add @clerk/clerk-js
35
+ ```
36
+
37
+ </CodeBlockTabs>
38
+
39
+ ## CLI upgrade helper
40
+
41
+ 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.
42
+
43
+ To run the CLI tool, navigate to your project and run it in the terminal:
44
+
45
+ <CodeBlockTabs type="installer" options={["npm", "yarn", "pnpm"]}>
46
+ ```bash filename="terminal"
47
+ npx @clerk/upgrade
48
+ ```
49
+
50
+ ```bash filename="terminal"
51
+ yarn dlx @clerk/upgrade
52
+ ```
53
+
54
+ ```bash filename="terminal"
55
+ pnpm dlx @clerk/upgrade
56
+ ```
57
+
58
+ </CodeBlockTabs>
59
+
60
+ 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.
61
+
62
+ ## Breaking Changes
63
+
64
+ ### Component design adjustments
65
+
66
+ 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.
67
+
68
+ [More detail on these changes &raquo;](component-redesign)
69
+
70
+ ### After sign up/in/out default value change
71
+
72
+ 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.
73
+
74
+ 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.
75
+
76
+ ```diff
77
+ - <UserButton afterSignOutUrl='/' />
78
+ + <UserButton />
79
+ ```
80
+
81
+ ### `afterSignXUrl` changes
82
+
83
+ 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.
84
+
85
+ > We will refer to these urls as `afterSignXUrl` where `X` could be `Up` or `In` depending on the context.
86
+
87
+ 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.
88
+
89
+ All `afterSignXUrl` props and `CLERK_AFTER_SIGN_X_URL` environment variables have been removed, and should be replaced by one of the following options:
90
+
91
+ - `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.
92
+ - `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.
93
+
94
+ 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:
95
+
96
+ ```diff
97
+ - <SignIn afterSignInUrl='/foo' />
98
+ + <SignIn signInFallbackRedirectUrl='/foo' />
99
+ ```
100
+
101
+ ### Removed: `orgs` claim on JWT
102
+
103
+ 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.
104
+
105
+ The `orgs` claim was part of the `JwtPayload`. Here are a few examples of where the `JwtPayload` could be found.
106
+
107
+ <Accordion titles={["Next.js", "Fastify", "@clerk/backend", "@clerk/clerk-sdk-node"]} heading="h5">
108
+ <AccordionPanel>
109
+ ```typescript filename="Next.js"
110
+ import { getAuth } from "@clerk/nextjs/server"
111
+ const claims: JwtPayload = getAuth(request).sessionClaims
112
+
113
+ import { getAuth } from "@clerk/ssr.server"
114
+ const claims: JwtPayload = (await getAuth(request)).sessionClaims
115
+ ```
116
+
117
+ </AccordionPanel>
118
+ <AccordionPanel>
119
+ ```typescript filename="Fastify"
120
+ import { getAuth } from "@clerk/fastify"
121
+ const claims: JwtPayload = (await getAuth(request)).sessionClaims
122
+ ```
123
+ </AccordionPanel>
124
+ <AccordionPanel>
125
+ ```typescript filename="@clerk/backend"
126
+ import { createClerkClient } from "@clerk/backend"
127
+
128
+ const clerkClient = createClerkClient({ secretKey: "" })
129
+ const requestState = await clerkClient.authenticateRequest(
130
+ request,
131
+ { publishableKey: "" }
132
+ )
133
+ const claims: JwtPayload = requestState.toAuth().sessionClaims
134
+ ```
135
+
136
+ </AccordionPanel>
137
+ <AccordionPanel>
138
+ ```typescript filename="@clerk/clerk-sdk-node"
139
+ import { clerkClient } from "@clerk/clerk-sdk-node"
140
+
141
+ router.use((...args) => clerkClient.expressRequireAuth()(...args))
142
+ router.get("/me", async (req, reply: Response) => {
143
+ return reply.json({ auth: req.auth })
144
+ })
145
+ ```
146
+
147
+ </AccordionPanel>
148
+ </Accordion>
149
+
150
+ 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.
151
+
152
+ ### Path routing is now the default
153
+
154
+ 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.
155
+
156
+ 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:
157
+
158
+ - `<SignIn />`
159
+ - `<SignUp />`
160
+ - `<UserProfile />`
161
+ - `<CreateOrganization />`
162
+ - `<OrganizationProfile />`
163
+
164
+ Here's how you'd use the components going forward:
165
+
166
+ ```jsx
167
+ <SignIn path="/sign-in" />
168
+ <SignUp path="/sign-up" />
169
+ <UserProfile path="/user-profile" />
170
+ <CreateOrganization path="/create-org" />
171
+ <OrganizationProfile path="/org-profile" />
172
+ ```
173
+
174
+ If you don't define the `path` prop an error will be thrown. Of course, you can still use `routing="hash"` or `routing="virtual"`.
175
+
176
+ ```jsx
177
+ <UserProfile routing="hash" />
178
+ <OrganizationProfile routing="virtual" />
179
+ ```
180
+
181
+
182
+
183
+ ### Image URL Name Consolidation
184
+
185
+ 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:
186
+
187
+ <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>"]}>
188
+ <AccordionPanel>
189
+ The `logoUrl` property of any [`Organization` object](https://clerk.com/docs/references/javascript/organization/organization#organization) has been changed to `imageUrl`.
190
+ </AccordionPanel>
191
+ <AccordionPanel>
192
+ The `profileImageUrl` property of any `User` object has been changed to `imageUrl`.
193
+ </AccordionPanel>
194
+ <AccordionPanel>
195
+ The `avatarUrl` property of any [`ExternalAcccount` object](https://clerk.com/docs/references/javascript/external-account) has been changed to `imageUrl`.
196
+ </AccordionPanel>
197
+ <AccordionPanel>
198
+ The `profileImageUrl` property of any `OrganizationMembershipPublicUserData` object has been changed to `imageUrl`.
199
+ </AccordionPanel>
200
+ </Accordion>
201
+
202
+ ### Changes to pagination arguments for some functions
203
+
204
+ There were some changes made to pagination-related arguments passed into functions, in order to make it more clear how to control paginated results. See each function impacted by these changes below:
205
+
206
+ <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"]}>
207
+ <AccordionPanel>
208
+ 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:
209
+
210
+ ```diff
211
+ const { data } = await organization.getRoles({
212
+ - limit: 10,
213
+ + pageSize: 10,
214
+ - offset: 10,
215
+ + initialPage: 2,
216
+ })
217
+ ```
218
+ </AccordionPanel>
219
+ <AccordionPanel>
220
+ 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:
221
+
222
+ ```diff
223
+ const { data } = await organization.getMemberships({
224
+ - limit: 10,
225
+ + pageSize: 10,
226
+ - offset: 10,
227
+ + initialPage: 2,
228
+ })
229
+ ```
230
+ </AccordionPanel>
231
+ <AccordionPanel>
232
+ 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:
233
+
234
+ ```diff
235
+ const { data } = await organization.getDomains({
236
+ - limit: 10,
237
+ + pageSize: 10,
238
+ - offset: 10,
239
+ + initialPage: 2,
240
+ })
241
+ ```
242
+ </AccordionPanel>
243
+ <AccordionPanel>
244
+ 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:
245
+
246
+ ```diff
247
+ const { data } = await organization.getInvitations({
248
+ - limit: 10,
249
+ + pageSize: 10,
250
+ - offset: 10,
251
+ + initialPage: 2,
252
+ })
253
+ ```
254
+ </AccordionPanel>
255
+ <AccordionPanel>
256
+ 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:
257
+
258
+ ```diff
259
+ const { data } = await organization.getMembershipRequests({
260
+ - limit: 10,
261
+ + pageSize: 10,
262
+ - offset: 10,
263
+ + initialPage: 2,
264
+ })
265
+ ```
266
+ </AccordionPanel>
267
+ <AccordionPanel>
268
+ 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:
269
+
270
+ ```diff
271
+ const { data } = await user.getOrganizationInvitations({
272
+ - limit: 10,
273
+ + pageSize: 10,
274
+ - offset: 10,
275
+ + initialPage: 2,
276
+ })
277
+ ```
278
+ </AccordionPanel>
279
+ <AccordionPanel>
280
+ 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:
281
+
282
+ ```diff
283
+ const { data } = await user.getOrganizationSuggestions({
284
+ - limit: 10,
285
+ + pageSize: 10,
286
+ - offset: 10,
287
+ + initialPage: 2,
288
+ })
289
+ ```
290
+ </AccordionPanel>
291
+ <AccordionPanel>
292
+ 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:
293
+
294
+ ```diff
295
+ const { data } = await user.getOrganizationMemberships({
296
+ - limit: 10,
297
+ + pageSize: 10,
298
+ - offset: 10,
299
+ + initialPage: 2,
300
+ })
301
+ ```
302
+ </AccordionPanel>
303
+ </Accordion>
304
+
305
+ ### Changes to some function return signatures
306
+
307
+ There have been changes to return signatures for some functions. Since Clerk's API responses are paginated, the `totalCount` property is helpful in determining the total number of items in the response easily. This change also aligns the response shape with what is returned from the Clerk backend API. Each impacted function is listed below, along with code examples:
308
+
309
+ <Accordion titles={["<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"]}>
310
+ <AccordionPanel>
311
+ 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.
312
+
313
+ Here's an example of how the response shape would change with this modification:
314
+
315
+ ```diff
316
+ - const data = await clerkClient.users.getOrganizationMembershipList()
317
+ + const { data, totalCount } = await clerkClient.users.getOrganizationMembershipList()
318
+ ```
319
+ </AccordionPanel>
320
+ <AccordionPanel>
321
+ 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.
322
+
323
+ Here's an example of how the response shape would change with this modification:
324
+
325
+ ```diff
326
+ - const data = await clerkClient.users.getOrganizationInvitationList()
327
+ + const { data, totalCount } = await clerkClient.users.getOrganizationInvitationList()
328
+ ```
329
+ </AccordionPanel>
330
+ <AccordionPanel>
331
+ 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:
332
+
333
+ ```diff
334
+ const data = await clerkClient.organizations.getOrganizationInvitationList({
335
+ organizationId: "...",
336
+ })
337
+
338
+ - data.forEach(() => {})
339
+ + data.data.forEach(() => {})
340
+ ```
341
+ </AccordionPanel>
342
+ <AccordionPanel>
343
+ 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:
344
+
345
+ ```diff
346
+ const { user } = useUser()
347
+ const membershipList = user.getOrganizationMembershipList()
348
+
349
+ - membershipList.forEach(() => {})
350
+ + membershipList.data.forEach(() => {})
351
+ ```
352
+ </AccordionPanel>
353
+ <AccordionPanel>
354
+ 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.
355
+
356
+ Here's an example of how the response shape would change with this modification:
357
+
358
+ ```diff
359
+ - const data = await clerkClient.users.getOrganizationList()
360
+ + const { data, totalCount } = await clerkClient.users.getOrganizationList()
361
+ ```
362
+ </AccordionPanel>
363
+ <AccordionPanel>
364
+ 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:
365
+
366
+ ```diff
367
+ const { organization } = useOrganization()
368
+ const orgList = organization.getOrganizationList()
369
+
370
+ - orgList.forEach(() => {})
371
+ + orgList.data.forEach(() => {})
372
+ ```
373
+ </AccordionPanel>
374
+ <AccordionPanel>
375
+ 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.
376
+
377
+ Here's an example of how the response shape would change with this modification:
378
+
379
+ ```diff
380
+ - const data = await clerkClient.invitations.getInvitationList()
381
+ + const { data, totalCount } = await clerkClient.invitations.getInvitationList()
382
+ ```
383
+ </AccordionPanel>
384
+ <AccordionPanel>
385
+ 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.
386
+
387
+ Here's an example of how the response shape would change with this modification:
388
+
389
+ ```diff
390
+ - const data = await clerkClient.sessions.getSessionList()
391
+ + const { data, totalCount } = await clerkClient.sessions.getSessionList()
392
+ ```
393
+ </AccordionPanel>
394
+ <AccordionPanel>
395
+ 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.
396
+
397
+ Here's an example of how the response shape would change with this modification:
398
+
399
+ ```diff
400
+ - const data = await clerkClient.users.getUserList()
401
+ + const { data, totalCount } = await clerkClient.users.getUserList()
402
+ ```
403
+ </AccordionPanel>
404
+ <AccordionPanel>
405
+ 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.
406
+
407
+ Here's an example of how the response shape would change with this modification:
408
+
409
+ ```diff
410
+ - const data = await clerkClient.allowlistIdentifiers.getAllowlistIdentifierList()
411
+ + const { data, totalCount } = await clerkClient.allowlistIdentifiers.getAllowlistIdentifierList()
412
+ ```
413
+ </AccordionPanel>
414
+ <AccordionPanel>
415
+ 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.
416
+
417
+ Here's an example of how the response shape would change with this modification:
418
+
419
+ ```diff
420
+ - const data = await clerkClient.clients.getClientList()
421
+ + const { data, totalCount } = await clerkClient.allowlistIdentifiers.getClientList()
422
+ ```
423
+ </AccordionPanel>
424
+ <AccordionPanel>
425
+ 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.
426
+
427
+ Here's an example of how the response shape would change with this modification:
428
+
429
+ ```diff
430
+ - const data = await clerkClient.redirectUrls.getRedirectUrlList()
431
+ + const { data, totalCount } = await clerkClient.redirectUrls.getRedirectUrlList()
432
+ ```
433
+ </AccordionPanel>
434
+ <AccordionPanel>
435
+ 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.
436
+
437
+ Here's an example of how the response shape would change with this modification:
438
+
439
+ ```diff
440
+ - const data = await clerkClient.users.getUserOauthAccessToken()
441
+ + const { data, totalCount } = await clerkClient.users.getUserOauthAccessToken()
442
+ ```
443
+ </AccordionPanel>
444
+ </Accordion>
445
+
446
+ ### Deprecation removals & housekeeping
447
+
448
+ 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.
449
+
450
+ <Callout type='info'>
451
+ For this section more than any other one, please use the CLI upgrade tool (`npx @clerk/upgrade`). Changes in this
452
+ section are very unlikely to appear in your codebase, the tool will save time looking for them.
453
+ </Callout>
454
+
455
+ #### Deprecation removals
456
+
457
+ <Accordion titles={["<code>User.update({ password: &#39;x&#39; })</code> -&gt; <code>User.updatePassword(&#39;x&#39;)</code>", "<code>Clerk.experimental_canUseCaptcha</code> property removed", "<code>Clerk.experimental_captchaURL</code> property removed", "<code>Clerk.experimental_captchaSiteKey</code> property removed", "<code>Clerk.__unstable__invitationUpdate</code> removed", "<code>Clerk.__unstable__membershipUpdate</code> removed", "<code>redirect_url</code> -&gt; <code>redirectUrl</code> as param of <code>User.createExternalAccount</code>", "<code>generatedSignature</code> -&gt; <code>signature</code> as param of <code>Signup.attemptWeb3WalletVerification</code>"]}>
458
+ <AccordionPanel>
459
+ 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:
460
+
461
+ ```diff
462
+ - user.update({ password: 'foo' });
463
+
464
+ + user.updatePassword({
465
+ + currentPassword: 'bar',
466
+ + newPassword: 'foo',
467
+ + signOutOfOtherSessions: true,
468
+ + });
469
+ ```
470
+ </AccordionPanel>
471
+ <AccordionPanel>
472
+ The experimental property `Clerk.experimental_canUseCaptcha` has been removed. There is no replacement for this functionality currently. If this is problematic for your application, please [reach out to our support team](https://clerk.com/support)!
473
+ </AccordionPanel>
474
+ <AccordionPanel>
475
+ The experimental property `Clerk.experimental_captchaURL` has been removed. There is no replacement for this functionality currently. If this is problematic for your application, please [reach out to our support team](https://clerk.com/support)!
476
+ </AccordionPanel>
477
+ <AccordionPanel>
478
+ The experimental property `Clerk.experimental_captchaSiteKey` has been removed. There is no replacement for this functionality currently. If this is problematic for your application, please [reach out to our support team](https://clerk.com/support)!
479
+ </AccordionPanel>
480
+ <AccordionPanel>
481
+ The `Clerk.__unstable__invitationUpdate` experimental property has been removed, and has no current replacement. If this is an issue in your codebase, please [reach out to Clerk support](https://clerk.com/support)!
482
+ </AccordionPanel>
483
+ <AccordionPanel>
484
+ The `Clerk.__unstable__membershipUpdate` experimental property has been removed, and has no current replacement. If this is an issue in your codebase, please [reach out to Clerk support](https://clerk.com/support)!
485
+ </AccordionPanel>
486
+ <AccordionPanel>
487
+ The param `redirect_url` of [`User.createExternalAccount`](https://clerk.com/docs/references/javascript/user/create-metadata#create-external-account) has been updated to `redirectUrl`. This is a simple text replacement without any signature changes.
488
+ </AccordionPanel>
489
+ <AccordionPanel>
490
+ The `generatedSignature` param to [`Signup.attemptWeb3WalletVerification()`](https://clerk.com/docs/references/javascript/sign-up/web3-verification#attempt-web3-wallet-verification) has been removed. Instead, use the `signature` param. Note that this param takes a string, where the `generatedSignature` param took a function, so both key and value will need to change.
491
+
492
+ ```js
493
+ // before
494
+ s.attemptWeb3WalletVerification({
495
+ generatedSignature: async () => 'signatureString',
496
+ });
497
+
498
+ // after
499
+ s.attemptWeb3WalletVerification({ signature: 'signatureString' });
500
+
501
+ // or, if you still need to fetch the signature async
502
+ const signatureString = await (async () => 'signatureString');
503
+ s.attemptWeb3WalletVerification({ signature: signatureString });
504
+ ```
505
+ </AccordionPanel>
506
+ </Accordion>
507
+
508
+ #### Other Breaking changes
509
+
510
+ <Accordion titles={["<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>", "<code>MagicLinkError</code> -&gt; <code>EmailLinkError</code>", "<code>isMagicLinkError</code> -&gt; <code>isEmailLinkError</code>", "<code>MagicLinkErrorCode</code> -&gt; <code>EmailLinkErrorCode</code>", "<code>useMagicLink</code> -&gt; <code>useEmailLink</code>", "<code>handleMagicLinkVerification</code> -&gt; <code>handleEmailLinkVerification</code>", "<code>[User|OrganizationMembershipPublicData].profileImageUrl</code> -&gt; <code>[User|OrganizationMembershipPublicData].imageUrl</code>", "<code>Clerk.getOrganizationMemberships()</code> -&gt; <code>user.getOrganizationMemberships()</code>", "<code>lastOrganizationInvitation</code> and <code>lastOrganizationMember</code> dropped from event emitter", "<code>Clerk.redirectToHome()</code> removed", "<code>Clerk.isReady()</code> removed", "Replace <code>signOutCallback</code> prop on <code>SignOutButton</code> with <code>redirectUrl</code>", "<code>Clerk</code> import changed"]}>
511
+ <AccordionPanel>
512
+ `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:
513
+
514
+ ```diff
515
+ - await setSession('sessionID', () => void)
516
+ + await setActive({ session: 'sessionID', beforeEmit: () => void })
517
+
518
+ - await setSession(sessionObj)
519
+ + await setActive({ session: sessionObj })
520
+
521
+ - await setSession(sessionObj, () => void)
522
+ + await setActive({ session: sessionObj, beforeEmit: () => void })
523
+ ```
524
+
525
+ `setActive` also supports setting an active organization:
526
+
527
+ ```js
528
+ await setActive({
529
+ session: 'sessionID',
530
+ organization: 'orgID',
531
+ beforeEmit: () => void
532
+ })
533
+
534
+ await setActive({
535
+ session: sessionObj,
536
+ organization: orgObj,
537
+ beforeEmit: () => void
538
+ })
539
+ ```
540
+ </AccordionPanel>
541
+ <AccordionPanel>
542
+ Passing a string as an argument to `Organization.create` is no longer possible - instead, pass an object with the `name` property.
543
+
544
+ ```diff
545
+ - Organization.create('...');
546
+ + Organization.create({ name: '...' });
547
+ ```
548
+ </AccordionPanel>
549
+ <AccordionPanel>
550
+ The `Organization.getPendingInvitations()` method has been removed. You can use `Organization.getInvitations` instead.
551
+
552
+ ```diff
553
+ - Organization.getPendingInvitations();
554
+ + Organization.getInvitations({ status: 'pending' });
555
+ ```
556
+ </AccordionPanel>
557
+ <AccordionPanel>
558
+ Across Clerk's documentation and codebases the term "magic link" was changed to "email link" as it more accurately reflects the functionality.
559
+ </AccordionPanel>
560
+ <AccordionPanel>
561
+ Across Clerk's documentation and codebases the term "magic link" was changed to "email link" as it more accurately reflects the functionality.
562
+ </AccordionPanel>
563
+ <AccordionPanel>
564
+ Across Clerk's documentation and codebases the term "magic link" was changed to "email link" as it more accurately reflects the functionality.
565
+ </AccordionPanel>
566
+ <AccordionPanel>
567
+ Across Clerk's documentation and codebases the term "magic link" was changed to "email link" as it more accurately reflects functionality.
568
+ </AccordionPanel>
569
+ <AccordionPanel>
570
+ Across Clerk's documentation and codebases the term "magic link" was changed to "email link" as it more accurately reflects functionality.
571
+ </AccordionPanel>
572
+ <AccordionPanel>
573
+ The `profileImageUrl` property of any [`User` object](https://clerk.com/docs/references/javascript/user/user#user) or [`OrganizationMembershipPublicData` object](https://github.com/clerk/javascript/blob/37f36e538d8879981f76f4a433066e057afb06de/packages/backend/src/api/resources/OrganizationMembership.ts#L31) has been changed to `imageUrl`.
574
+ </AccordionPanel>
575
+ <AccordionPanel>
576
+ The `getOrganizationMemberships` [method on the `Clerk` class](https://clerk.com/docs/references/javascript/clerk/clerk#organization) has been removed. Instead, use `getOrganizationMemberships` on a user instance.
577
+
578
+ ```diff
579
+ - Clerk.getOrganizationMemberships();
580
+ + user.getOrganizationMemberships();
581
+ ```
582
+ </AccordionPanel>
583
+ <AccordionPanel>
584
+ If you are using [`Clerk.addListener`](https://clerk.com/docs/references/javascript/clerk/clerk#add-listener) or `OrganizationContext` and utilizing either the `lastOrganizationInvitation` and/or `lastOrganizationMember` emitted events, these properties have been removed, as they were only relevant for internal use. We are not providing a way to backfill this functionality at the moment. If you are using it and this is an issue for you, please [reach out to Clerk support](https://clerk.com/support) and we can find a way to resolve the issue!
585
+ </AccordionPanel>
586
+ <AccordionPanel>
587
+ The `Clerk.redirectToHome` method has been removed. If you are looking for a generic replacement for this method, you can instead use `window.Clerk.redirectToAfterSignUp()` or `window.Clerk.redirectAfterSignIn()`.
588
+
589
+ To set the `afterSignUpUrl` or `afterSignInUrl`, you can:
590
+
591
+ - If not using a react-based SDK, pass the values into `Clerk.load` as such: `Clerk.load({ afterSignUpUrl: 'x', afterSignInUrl: 'y' })`
592
+ - If using a react-based SDK, [pass the desired values into ClerkProvider](https://clerk.com/docs/components/clerk-provider#properties)
593
+ - If using the Next.js SDK, set with `NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL` or `NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL`
594
+ - If using remix SDK, set with `CLERK_AFTER_SIGN_IN_URL` or `CLERK_AFTER_SIGN_UP_URL`
595
+ </AccordionPanel>
596
+ <AccordionPanel>
597
+ We have removed the `Clerk.isReady()` function - instead, please use the `Clerk.loaded` property to check whether Clerk has completed loading.
598
+ </AccordionPanel>
599
+ <AccordionPanel>
600
+ 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:
601
+
602
+ ```diff
603
+ import { SignOutButton } from "@clerk/clerk-react";
604
+
605
+ export const Signout = () => {
606
+ return (
607
+ <SignOutButton
608
+ - signOutCallback={() => { window.location.href = "/your-path" }}
609
+ + redirectUrl="/your-path"
610
+ >
611
+ <button>Sign Out</button>
612
+ </SignOutButton>
613
+ )
614
+ }
615
+ ```
616
+ </AccordionPanel>
617
+ <AccordionPanel>
618
+ The top level `Clerk` import was changed to a named export, like `{ Clerk }`. This is just a name change and can be treated as a text replacement, no changes to the params or return types.
619
+
620
+ ```diff
621
+ - import Clerk from '@clerk/clerk-js';
622
+ + import { Clerk } from '@clerk/clerk-js';
623
+ ```
624
+ </AccordionPanel>
625
+ </Accordion>
626
+
627
+
628
+