@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,592 @@
1
+ ---
2
+ title: "Upgrading Node to Core 2"
3
+ description: "Learn how to upgrade Clerk's Node SDK to the lastest 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-sdk-node` to Core 2
9
+
10
+ Core 2 is included in the Node.js SDK starting with version 5. This new version ships with 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 Node project to use `@clerk/clerk-sdk-node` 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-sdk-node@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 to Core 2
25
+
26
+ 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.
27
+
28
+ <CodeBlockTabs type="installer" options={["npm", "yarn", "pnpm"]}>
29
+ ```bash filename="terminal"
30
+ npm install @clerk/clerk-sdk-node
31
+ ```
32
+
33
+ ```bash filename="terminal"
34
+ yarn add @clerk/clerk-sdk-node
35
+ ```
36
+
37
+ ```bash filename="terminal"
38
+ pnpm add @clerk/clerk-sdk-node
39
+ ```
40
+
41
+ </CodeBlockTabs>
42
+
43
+ ## CLI upgrade helper
44
+
45
+ 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.
46
+
47
+ To run the CLI tool, navigate to your project and run it in the terminal:
48
+
49
+ <CodeBlockTabs type="installer" options={["npm", "yarn", "pnpm"]}>
50
+ ```bash filename="terminal"
51
+ npx @clerk/upgrade
52
+ ```
53
+
54
+ ```bash filename="terminal"
55
+ yarn dlx @clerk/upgrade
56
+ ```
57
+
58
+ ```bash filename="terminal"
59
+ pnpm dlx @clerk/upgrade
60
+ ```
61
+
62
+ </CodeBlockTabs>
63
+
64
+ 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.
65
+
66
+ ## Breaking Changes
67
+
68
+ ### `cjs/instance` and `esm/instance` imports no longer needed
69
+
70
+ If you are using either of these import paths, they are no longer necessary and you can import directly from the top level `@clerk/express` path.
71
+
72
+ ```diff
73
+ - import { ... } from "@clerk/clerk-sdk-node/esm/instance";
74
+ - import { ... } from "@clerk/clerk-sdk-node/cjs/instance";
75
+ + import { ... } from "@clerk/clerk-sdk-node";
76
+ ```
77
+
78
+ ### Clerk client setters removed in favor of `createClerkClient` options
79
+
80
+ The following setter methods have been removed in the lastest version. If you were using any of these functions, their functionality can be replaced by instead passing the correponding option to `createClerkClient`.
81
+
82
+ - `setClerkApiVersion`
83
+ - `setClerkHttpOptions`
84
+ - `setClerkServerApiUrl`
85
+ - `setClerkApiKey`
86
+
87
+ Code example:
88
+
89
+ ```diff
90
+ import {
91
+ clerkClient,
92
+ - setClerkApiKey,
93
+ - setClerkApiVersion,
94
+ - setClerkHttpOptions,
95
+ - setClerkServerApiUrl
96
+ } from "@clerk/clerk-sdk-node"
97
+
98
+ - setClerkApiKey("...")
99
+ - setClerkApiVersion("...")
100
+ - setClerkHttpOptions("...")
101
+ - setClerkServerApiUrl("...")
102
+
103
+ const clerkClient = createClerkClient({
104
+ + secretKey: "..."
105
+ + apiVersion: "..."
106
+ + httpOptions: "..."
107
+ + serverApiUrl: "..."
108
+ })
109
+
110
+ await clerkClient.users.getUser(userId);
111
+ ```
112
+
113
+ ### Removed: `orgs` claim on JWT
114
+
115
+ 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.
116
+
117
+ The `orgs` claim was part of the `JwtPayload`. Here are a few examples of where the `JwtPayload` could be found.
118
+
119
+ <Accordion titles={["Next.js", "Fastify", "@clerk/backend", "@clerk/clerk-sdk-node"]} heading="h5">
120
+ <AccordionPanel>
121
+ ```typescript filename="Next.js"
122
+ import { getAuth } from "@clerk/nextjs/server"
123
+ const claims: JwtPayload = getAuth(request).sessionClaims
124
+
125
+ import { getAuth } from "@clerk/ssr.server"
126
+ const claims: JwtPayload = (await getAuth(request)).sessionClaims
127
+ ```
128
+
129
+ </AccordionPanel>
130
+ <AccordionPanel>
131
+ ```typescript filename="Fastify"
132
+ import { getAuth } from "@clerk/fastify"
133
+ const claims: JwtPayload = (await getAuth(request)).sessionClaims
134
+ ```
135
+ </AccordionPanel>
136
+ <AccordionPanel>
137
+ ```typescript filename="@clerk/backend"
138
+ import { createClerkClient } from "@clerk/backend"
139
+
140
+ const clerkClient = createClerkClient({ secretKey: "" })
141
+ const requestState = await clerkClient.authenticateRequest(
142
+ request,
143
+ { publishableKey: "" }
144
+ )
145
+ const claims: JwtPayload = requestState.toAuth().sessionClaims
146
+ ```
147
+
148
+ </AccordionPanel>
149
+ <AccordionPanel>
150
+ ```typescript filename="@clerk/clerk-sdk-node"
151
+ import { clerkClient } from "@clerk/clerk-sdk-node"
152
+
153
+ router.use((...args) => clerkClient.expressRequireAuth()(...args))
154
+ router.get("/me", async (req, reply: Response) => {
155
+ return reply.json({ auth: req.auth })
156
+ })
157
+ ```
158
+
159
+ </AccordionPanel>
160
+ </Accordion>
161
+
162
+ 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.
163
+
164
+ ### Image URL Name Consolidation
165
+
166
+ 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:
167
+
168
+ <Accordion titles={["<code>Organization.logoUrl</code> -&gt; <code>Organization.imageUrl</code>", "<code>User.profileImageUrl</code> -&gt; <code>.imageUrl</code>", "<code>OrganizationMembershipPublicUserData.profileImageUrl</code> -&gt; <code>.imageUrl</code>", "<code>ExternalAccount.picture</code> -&gt; <code>.imageUrl</code>"]}>
169
+ <AccordionPanel>
170
+ The `logoUrl` property of any [`Organization` object](https://clerk.com/docs/references/javascript/organization/organization#organization) has been changed to `imageUrl`.
171
+ </AccordionPanel>
172
+ <AccordionPanel>
173
+ The `profileImageUrl` property of any `User` object has been changed to `imageUrl`.
174
+ </AccordionPanel>
175
+ <AccordionPanel>
176
+ The `profileImageUrl` property of any `OrganizationMembershipPublicUserData` object has been changed to `imageUrl`.
177
+ </AccordionPanel>
178
+ <AccordionPanel>
179
+ The `picture` property of any [`ExternalAcccount` object](https://clerk.com/docs/references/javascript/external-account) has been changed to `imageUrl`.
180
+ </AccordionPanel>
181
+ </Accordion>
182
+
183
+ ### Deprecation removals & housekeeping
184
+
185
+ 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.
186
+
187
+ <Callout type='info'>
188
+ For this section more than any other one, please use the CLI upgrade tool (`npx @clerk/upgrade`). Changes in this
189
+ section are very unlikely to appear in your codebase, the tool will save time looking for them.
190
+ </Callout>
191
+
192
+ #### Deprecation removals
193
+
194
+ <Accordion titles={["<code>User.update({ password: &#39;x&#39; })</code> -&gt; <code>User.updatePassword(&#39;x&#39;)</code>", "<code>CLERK_API_KEY</code> replaced by <code>CLERK_SECRET_KEY</code>", "<code>CLERK_FRONTEND_API</code> replaced by <code>CLERK_PUBLISHABLE_KEY</code>", "<code>apiKey</code> -&gt; <code>secretKey</code> as param to ClerkExpressRequireAuth", "<code>apiKey</code> -&gt; <code>secretKey</code> as param to ClerkExpressWithAuth", "<code>apiKey</code> -&gt; <code>secretKey</code> as param to createClerkClient", "<code>apiKey</code> -&gt; <code>secretKey</code> as param to createClerkExpressRequireAuth", "<code>apiKey</code> -&gt; <code>secretKey</code> as param to createClerkExpressWithAuth", "<code>frontendApi</code> -&gt; <code>publishableKey</code> as param to createClerkClient", "<code>frontendApi</code> -&gt; <code>publishableKey</code> as param to createClerkExpressRequireAuth", "<code>frontendApi</code> -&gt; <code>publishableKey</code> as param to ClerkExpressRequireAuth", "<code>frontendApi</code> -&gt; <code>publishableKey</code> as param to createClerkExpressWithAuth", "<code>frontendApi</code> -&gt; <code>publishableKey</code> as param to ClerkExpressWithAuth"]}>
195
+ <AccordionPanel>
196
+ 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:
197
+
198
+ ```diff
199
+ - user.update({ password: 'foo' });
200
+
201
+ + user.updatePassword({
202
+ + currentPassword: 'bar',
203
+ + newPassword: 'foo',
204
+ + signOutOfOtherSessions: true,
205
+ + });
206
+ ```
207
+ </AccordionPanel>
208
+ <AccordionPanel>
209
+ The `CLERK_API_KEY` environment variable was renamed to `CLERK_SECRET_KEY`. 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).
210
+ </AccordionPanel>
211
+ <AccordionPanel>
212
+ The `CLERK_FRONTEND_API` environment variable was renamed to `CLERK_PUBLISHABLE_KEY`. 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). **Note:** The values are different, so this is not just a key replacement. [More information](/docs/deployments/overview#api-keys-and-environment-variables).
213
+ </AccordionPanel>
214
+ <AccordionPanel>
215
+ The `apiKey` argument passed to `ClerkExpressRequireAuth` must be changed to `secretKey`.
216
+
217
+ ```diff
218
+ import { ClerkExpressRequireAuth } from '@clerk/clerk-sdk-node';
219
+
220
+ - ClerkExpressRequireAuth({ apiKey: '...' });
221
+ + ClerkExpressRequireAuth({ secretKey: '...' });
222
+ ```
223
+ </AccordionPanel>
224
+ <AccordionPanel>
225
+ The `apiKey` argument passed to `ClerkExpressWithAuth` must be changed to `secretKey`.
226
+
227
+ ```diff
228
+ import { ClerkExpressWithAuth } from '@clerk/clerk-sdk-node';
229
+
230
+ - ClerkExpressWithAuth({ apiKey: '...' });
231
+ + ClerkExpressWithAuth({ secretKey: '...' });
232
+ ```
233
+ </AccordionPanel>
234
+ <AccordionPanel>
235
+ The `apiKey` argument passed to `createClerkClient` must be changed to `secretKey`.
236
+
237
+ ```diff
238
+ import { createClerkClient } from '@clerk/clerk-sdk-node';
239
+
240
+ - createClerkClient({ apiKey: '...' });
241
+ + createClerkClient({ secretKey: '...' });
242
+ ```
243
+ </AccordionPanel>
244
+ <AccordionPanel>
245
+ The `apiKey` argument passed to `createClerkExpressRequireAuth` must be changed to `secretKey`.
246
+
247
+ ```diff
248
+ import { createClerkExpressRequireAuth } from '@clerk/clerk-sdk-node';
249
+
250
+ - createClerkExpressRequireAuth({ apiKey: '...' });
251
+ + createClerkExpressRequireAuth({ secretKey: '...' });
252
+ ```
253
+ </AccordionPanel>
254
+ <AccordionPanel>
255
+ The `apiKey` argument passed to `createClerkExpressWithAuth` must be changed to `secretKey`.
256
+
257
+ ```diff
258
+ import { createClerkExpressWithAuth } from '@clerk/clerk-sdk-node';
259
+
260
+ - createClerkExpressWithAuth({ apiKey: '...' });
261
+ + createClerkExpressWithAuth({ secretKey: '...' });
262
+ ```
263
+ </AccordionPanel>
264
+ <AccordionPanel>
265
+ The `frontendApi` argument passed to `createClerkClient` must be changed to `publishableKey`. Note that the values of the two keys are different, so both keys and values need to be changed. You can find your application's publishable key in the Clerk dashboard.
266
+
267
+ ```diff
268
+ import { createClerkClient } from '@clerk/clerk-sdk-node';
269
+
270
+ - createClerkClient({ frontendApi: '...' });
271
+ + createClerkClient({ publishableKey: '...' });
272
+ ```
273
+ </AccordionPanel>
274
+ <AccordionPanel>
275
+ The `frontendApi` argument passed to `createClerkExpressRequireAuth` must be changed to `publishableKey`. Note that the values of the two keys are different, so both keys and values need to be changed. You can find your application's publishable key in the Clerk dashboard.
276
+
277
+ ```diff
278
+ import { createClerkExpressRequireAuth } from '@clerk/clerk-sdk-node';
279
+
280
+ - createClerkExpressRequireAuth({ frontendApi: '...' });
281
+ + createClerkExpressRequireAuth({ publishableKey: '...' });
282
+ ```
283
+ </AccordionPanel>
284
+ <AccordionPanel>
285
+ The `frontendApi` argument passed to `ClerkExpressRequireAuth` must be changed to `publishableKey`. Note that the values of the two keys are different, so both keys and values need to be changed. You can find your application's publishable key in the Clerk dashboard.
286
+
287
+ ```diff
288
+ import { ClerkExpressRequireAuth } from '@clerk/clerk-sdk-node';
289
+
290
+ - ClerkExpressRequireAuth({ frontendApi: '...' });
291
+ + ClerkExpressRequireAuth({ publishableKey: '...' });
292
+ ```
293
+ </AccordionPanel>
294
+ <AccordionPanel>
295
+ The `frontendApi` argument passed to `createClerkExpressWithAuth` must be changed to `publishableKey`. Note that the values of the two keys are different, so both keys and values need to be changed. You can find your application's publishable key in the Clerk dashboard.
296
+
297
+ ```diff
298
+ import { createClerkExpressWithAuth } from '@clerk/clerk-sdk-node';
299
+
300
+ - createClerkExpressWithAuth({ frontendApi: '...' });
301
+ + createClerkExpressWithAuth({ publishableKey: '...' });
302
+ ```
303
+ </AccordionPanel>
304
+ <AccordionPanel>
305
+ The `frontendApi` argument passed to `ClerkExpressWithAuth` must be changed to `publishableKey`. Note that the values of the two keys are different, so both keys and values need to be changed. You can find your application's publishable key in the Clerk dashboard.
306
+
307
+ ```diff
308
+ import { ClerkExpressWithAuth } from '@clerk/clerk-sdk-node';
309
+
310
+ - ClerkExpressWithAuth({ frontendApi: '...' });
311
+ + ClerkExpressWithAuth({ publishableKey: '...' });
312
+ ```
313
+ </AccordionPanel>
314
+ </Accordion>
315
+
316
+ #### Other Breaking changes
317
+
318
+ <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>API_URL</code> value has changed", "<code>LegacyAuthObject</code> type -&gt; <code>AuthObject</code>", "<code>Clerk</code> -&gt; <code>{ createClerkClient }</code>", "<code>createClerkExpressRequireAuth</code> requires publishable key", "<code>createClerkExpressWithAuth</code> requires publishable key"]}>
319
+ <AccordionPanel>
320
+ 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:
321
+
322
+ ```diff
323
+ const { data } = await organization.getRoles({
324
+ - limit: 10,
325
+ + pageSize: 10,
326
+ - offset: 10,
327
+ + initialPage: 2,
328
+ })
329
+ ```
330
+ </AccordionPanel>
331
+ <AccordionPanel>
332
+ 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:
333
+
334
+ ```diff
335
+ const { data } = await organization.getMemberships({
336
+ - limit: 10,
337
+ + pageSize: 10,
338
+ - offset: 10,
339
+ + initialPage: 2,
340
+ })
341
+ ```
342
+ </AccordionPanel>
343
+ <AccordionPanel>
344
+ 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:
345
+
346
+ ```diff
347
+ const { data } = await organization.getDomains({
348
+ - limit: 10,
349
+ + pageSize: 10,
350
+ - offset: 10,
351
+ + initialPage: 2,
352
+ })
353
+ ```
354
+ </AccordionPanel>
355
+ <AccordionPanel>
356
+ 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:
357
+
358
+ ```diff
359
+ const { data } = await organization.getInvitations({
360
+ - limit: 10,
361
+ + pageSize: 10,
362
+ - offset: 10,
363
+ + initialPage: 2,
364
+ })
365
+ ```
366
+ </AccordionPanel>
367
+ <AccordionPanel>
368
+ 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:
369
+
370
+ ```diff
371
+ const { data } = await organization.getMembershipRequests({
372
+ - limit: 10,
373
+ + pageSize: 10,
374
+ - offset: 10,
375
+ + initialPage: 2,
376
+ })
377
+ ```
378
+ </AccordionPanel>
379
+ <AccordionPanel>
380
+ 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:
381
+
382
+ ```diff
383
+ const { data } = await user.getOrganizationInvitations({
384
+ - limit: 10,
385
+ + pageSize: 10,
386
+ - offset: 10,
387
+ + initialPage: 2,
388
+ })
389
+ ```
390
+ </AccordionPanel>
391
+ <AccordionPanel>
392
+ 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:
393
+
394
+ ```diff
395
+ const { data } = await user.getOrganizationSuggestions({
396
+ - limit: 10,
397
+ + pageSize: 10,
398
+ - offset: 10,
399
+ + initialPage: 2,
400
+ })
401
+ ```
402
+ </AccordionPanel>
403
+ <AccordionPanel>
404
+ 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:
405
+
406
+ ```diff
407
+ const { data } = await user.getOrganizationMemberships({
408
+ - limit: 10,
409
+ + pageSize: 10,
410
+ - offset: 10,
411
+ + initialPage: 2,
412
+ })
413
+ ```
414
+ </AccordionPanel>
415
+ <AccordionPanel>
416
+ 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.
417
+
418
+ Here's an example of how the response shape would change with this modification:
419
+
420
+ ```diff
421
+ - const data = await clerkClient.users.getOrganizationMembershipList()
422
+ + const { data, totalCount } = await clerkClient.users.getOrganizationMembershipList()
423
+ ```
424
+ </AccordionPanel>
425
+ <AccordionPanel>
426
+ 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.
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.getOrganizationInvitationList()
432
+ + const { data, totalCount } = await clerkClient.users.getOrganizationInvitationList()
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 data = await clerkClient.organizations.getOrganizationInvitationList({
440
+ organizationId: "...",
441
+ })
442
+
443
+ - data.forEach(() => {})
444
+ + data.data.forEach(() => {})
445
+ ```
446
+ </AccordionPanel>
447
+ <AccordionPanel>
448
+ 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:
449
+
450
+ ```diff
451
+ const { user } = useUser()
452
+ const membershipList = user.getOrganizationMembershipList()
453
+
454
+ - membershipList.forEach(() => {})
455
+ + membershipList.data.forEach(() => {})
456
+ ```
457
+ </AccordionPanel>
458
+ <AccordionPanel>
459
+ 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.
460
+
461
+ Here's an example of how the response shape would change with this modification:
462
+
463
+ ```diff
464
+ - const data = await clerkClient.users.getOrganizationList()
465
+ + const { data, totalCount } = await clerkClient.users.getOrganizationList()
466
+ ```
467
+ </AccordionPanel>
468
+ <AccordionPanel>
469
+ 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:
470
+
471
+ ```diff
472
+ const { organization } = useOrganization()
473
+ const orgList = organization.getOrganizationList()
474
+
475
+ - orgList.forEach(() => {})
476
+ + orgList.data.forEach(() => {})
477
+ ```
478
+ </AccordionPanel>
479
+ <AccordionPanel>
480
+ 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.
481
+
482
+ Here's an example of how the response shape would change with this modification:
483
+
484
+ ```diff
485
+ - const data = await clerkClient.invitations.getInvitationList()
486
+ + const { data, totalCount } = await clerkClient.invitations.getInvitationList()
487
+ ```
488
+ </AccordionPanel>
489
+ <AccordionPanel>
490
+ 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.
491
+
492
+ Here's an example of how the response shape would change with this modification:
493
+
494
+ ```diff
495
+ - const data = await clerkClient.sessions.getSessionList()
496
+ + const { data, totalCount } = await clerkClient.sessions.getSessionList()
497
+ ```
498
+ </AccordionPanel>
499
+ <AccordionPanel>
500
+ 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.
501
+
502
+ Here's an example of how the response shape would change with this modification:
503
+
504
+ ```diff
505
+ - const data = await clerkClient.users.getUserList()
506
+ + const { data, totalCount } = await clerkClient.users.getUserList()
507
+ ```
508
+ </AccordionPanel>
509
+ <AccordionPanel>
510
+ 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.
511
+
512
+ Here's an example of how the response shape would change with this modification:
513
+
514
+ ```diff
515
+ - const data = await clerkClient.allowlistIdentifiers.getAllowlistIdentifierList()
516
+ + const { data, totalCount } = await clerkClient.allowlistIdentifiers.getAllowlistIdentifierList()
517
+ ```
518
+ </AccordionPanel>
519
+ <AccordionPanel>
520
+ 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.
521
+
522
+ Here's an example of how the response shape would change with this modification:
523
+
524
+ ```diff
525
+ - const data = await clerkClient.clients.getClientList()
526
+ + const { data, totalCount } = await clerkClient.allowlistIdentifiers.getClientList()
527
+ ```
528
+ </AccordionPanel>
529
+ <AccordionPanel>
530
+ 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.
531
+
532
+ Here's an example of how the response shape would change with this modification:
533
+
534
+ ```diff
535
+ - const data = await clerkClient.redirectUrls.getRedirectUrlList()
536
+ + const { data, totalCount } = await clerkClient.redirectUrls.getRedirectUrlList()
537
+ ```
538
+ </AccordionPanel>
539
+ <AccordionPanel>
540
+ 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.
541
+
542
+ Here's an example of how the response shape would change with this modification:
543
+
544
+ ```diff
545
+ - const data = await clerkClient.users.getUserOauthAccessToken()
546
+ + const { data, totalCount } = await clerkClient.users.getUserOauthAccessToken()
547
+ ```
548
+ </AccordionPanel>
549
+ <AccordionPanel>
550
+ The value of this export has changed from `https://api.clerk.dev` to `https://api.clerk.com`. If you were relying on the text content of this value not changing, you may need to make adjustments.
551
+ </AccordionPanel>
552
+ <AccordionPanel>
553
+ We changed the values that our middleware adds to the `request` object after running. Previously it returned a `LegacyAuthObject` type, and now it returns an `AuthObject` type, the difference between the two types is as such:
554
+
555
+ ```diff
556
+ - type LegacyAuthObject = {
557
+ + type AuthObject = {
558
+ sessionId: string | null;
559
+ actor: ActClaim | undefined | null;
560
+ userId: string | null;
561
+ getToken: ServerGetToken | null;
562
+ debug: AuthObjectDebug | null;
563
+ - claims: JwtPayload | null;
564
+ + sessionClaims: JwtPayload | null;
565
+ + orgId: string | undefined | null;
566
+ + orgRole: OrganizationCustomRoleKey | undefined | null;
567
+ + orgSlug: string | undefined | null;
568
+ + orgPermissions: OrganizationCustomPermissionKey[] | undefined | null;
569
+ + has: CheckAuthorizationWithCustomPermissions | null;
570
+ }
571
+ ```
572
+
573
+ If you were using the `claims` key on the request after running middleware, you will need to instead use `sessionClaims`. Additionally, if you were using the `LooseAuthProp` or `StrictAuthProp` exported types anywhere, note that these have been adjusted to fit the shape of the new middleware response typing.
574
+ </AccordionPanel>
575
+ <AccordionPanel>
576
+ The `Clerk` default import has changed to `createClerkClient` and been moved to a named import rather than default. You must update your import path in order for it to work correctly. Example below of the fix that needs to be made:
577
+
578
+ ```diff
579
+ - import Clerk from "@clerk/clerk-sdk-node"
580
+ + import { createClerkClient } from "@clerk/clerk-sdk-node"
581
+ ```
582
+ </AccordionPanel>
583
+ <AccordionPanel>
584
+ The `createClerkExpressRequireAuth` method now requires a clerk public key in order to work correctly. It can be passed in as a parameter directly, or picked up via environment variable. An error will be thrown now if there's no public key provided, this was not previously the case.
585
+ </AccordionPanel>
586
+ <AccordionPanel>
587
+ The `createClerkExpressWithAuth` method now requires a clerk public key in order to work correctly. It can be passed in as a parameter directly, or picked up via environment variable. An error will be thrown now if there's no public key provided, this was not previously the case.
588
+ </AccordionPanel>
589
+ </Accordion>
590
+
591
+
592
+
@@ -0,0 +1,33 @@
1
+ ---
2
+ title: "Upgrading to Clerk Core 2"
3
+ description: "Learn how to upgrade to the latest version of Clerk's SDKs"
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 to Clerk Core 2
9
+
10
+ In Febrary 2024, [we updated](https://clerk.com/changelog/2024-01-16) Clerk's SDKs to include Core 2. This new core includes:
11
+
12
+ - 💅 Redesigned and improved component UIs.
13
+ - 🔪 The 401 & "flash of white page" that was visible sometimes when syncing auth state was eliminated.
14
+ - 🧹 A large number of smaller housekeeping changes, bugfixes, and improvements.
15
+ - 📊 [Telemetry](/docs/telemetry) to allow us to better determine feature usage and priority (easy opt-out if you don't like this)
16
+
17
+ ## SDK Guides
18
+
19
+ Core 2 brings both UI changes and breaking code changes, so each SDK has been updated to a new major version.
20
+ We expect upgrades to take less than 30 minutes, and are providing a CLI tool to assist with the process. Please select your SDK below to get started:
21
+
22
+ - [Next.js](/nextjs)
23
+ - [Remix](/remix)
24
+ - [Expo](/expo)
25
+ - [Node](/node)
26
+ - [Fastify](/fastify)
27
+ - [React](/react)
28
+ - [Backend](/backend)
29
+ - [JS](/js)
30
+ - [Chrome Extension](/chrome-extension)
31
+
32
+ Note that the `Gastsby`, `Go`, and `Ruby` SDKs do not yet have a core 2 release ready - if you are using any of these SDKs there is nothing actionable right now.
33
+
@@ -22,4 +22,4 @@ We expect upgrades to take less than 30 minutes, and are providing a CLI tool to
22
22
  - [JS](/js)
23
23
  - [Chrome Extension](/chrome-extension)
24
24
 
25
- Note that the `Gastsby`, `Go`, and `Ruby` SDKs do not yet have a beta release ready - if you are using any of these SDKs there is nothing actionable right now.
25
+ Note that the `Gastsby`, `Go`, and `Ruby` SDKs do not yet have a core 2 release ready - if you are using any of these SDKs there is nothing actionable right now.