Skip to content

Commit

Permalink
v5 updates (#619)
Browse files Browse the repository at this point in the history
Co-authored-by: Lennart <[email protected]>
  • Loading branch information
2 people authored and S3Prototype committed Apr 3, 2024
1 parent ea9c9a4 commit c503100
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 67 deletions.
6 changes: 3 additions & 3 deletions docs/components/clerk-provider.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The `<ClerkProvider>` component must be added to your React entrypoint.
<Tab>
The `<ClerkProvider>` component needs to access headers to authenticate correctly. This means anything wrapped by the provider will be opted into dynamic rendering at request time. If you have static-optimized or ISR pages that you would prefer not to be opted into dynamic rendering, make sure they are not wrapped by `<ClerkProvider>`.

This is easiest to accomplish by ensuring that `<ClerkProvider>` is added further down the tree to wrap route groups that explicitly need authentication instead of having the provider wrap your application root as recommended above. For example, if your project includes a set of landing/marketing pages as well as a dashboard that requires sign in, you would create separate (marketing) and (dashboard) route groups. Adding `<ClerkProvider>` to the `(dashboard)/layout.jsx` layout file will ensure that only those routes are opted into dynamic rendering, allowing the marketing routes to be statically optimized.
This is easiest to accomplish by ensuring that `<ClerkProvider>` is added further down the tree to wrap route groups that explicitly need authentication instead of having the provider wrap your application root as recommended above. For example, if your project includes a set of landing/marketing pages as well as a dashboard that requires login, you would create separate (marketing) and (dashboard) route groups. Adding `<ClerkProvider>` to the `(dashboard)/layout.jsx` layout file will ensure that only those routes are opted into dynamic rendering, allowing the marketing routes to be statically optimized.

<CodeBlockTabs type="router" options={["App Router", "Pages Router"]}>

Expand Down Expand Up @@ -99,8 +99,8 @@ The `<ClerkProvider>` component must be added to your React entrypoint.
| `appearance?` | <code>[Appearance](/docs/components/customization/overview) \| undefined</code> | Optional object to style your components. Will only affect [Clerk Components][components-ref] and not [Account Portal][ap-ref] pages. |
| `localization` | <code>[Localization](/docs/components/customization/localization) \| undefined</code> | Optional object to localize your components. Will only affect [Clerk Components][components-ref] and not [Account Portal][ap-ref] pages. |
| `allowedRedirectOrigins?` | `Array<string \| RegExp>` | Optional array of domains used to validate against the query param of an auth redirect. If no match is made, the redirect is considered unsafe and the default redirect will be used with a warning passed to the console. |
| `afterSignInUrl?` | `string` | The default URL to use after the user signs in. Defaults to `/`. |
| `afterSignUpUrl?` | `string` | The default URL to use after the user signs up. Defaults to `/`. |
| `afterSignInUrl?` | `string` | The default URL to use after the user signs in. |
| `afterSignUpUrl?` | `string` | The default URL to use after the user signs up. |
| `isSatellite?` | `boolean \| ((url: URL) => boolean)` | This option defines that the application is a satellite application. |
| `domain?` | `string \| ((url: URL) => boolean)` | This option sets the domain of the satellite application. If your application is a satellite application, this option is required. |
| `signInUrl` | `string` | This url will be used for any redirects that might happen and needs to point to your primary application. This option is optional for production instances and required for development instances. |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
---
title: getOrganizationInvitationList()
description: Use Clerk's Backend SDK to retrieve a list of organization invitations that have not yet been accepted.
description: Retrieves a list of organization invitations that have not yet been accepted.
---

# `getOrganizationInvitationList()`

Retrieves a list of organization invitations that have not yet been accepted.

```tsx
function getOrganizationInvitationList: (params: GetOrganizationInvitationListParams) => Promise<PaginatedResourceResponse<OrganizationInvitation[]>>;
const organizationId = 'my-organization-id';

const invitations = await clerkClient.organizations.getOrganizationInvitationList({ organizationId });
```

## `GetOrganizationInvitationListParams`
Expand All @@ -20,91 +22,46 @@ function getOrganizationInvitationList: (params: GetOrganizationInvitationListPa
| `limit?` | `number` | The number of results to return. Must be an integer greater than zero and less than 500. |
| `offset?` | `number` | The number of results to skip. |

## `getOrganizationInvitationList()` examples

### `getOrganizationInvitationList({ organizationId})`

In this example, you can see that the returned [`PaginatedResourceResponse`](/docs/references/backend/types/paginated-resource-response) includes `data`, which is an array of [`OrganizationInvitation`](/docs/references/javascript/organization-invitation) objects, and `totalCount`, which indicates the total number of organization invitations in the system for the specified organization.

```tsx
const organizationId = 'org_2ZUtbk2yvnFGItdeze1ivCh3uqh';

const response = await clerkClient.organizations.getOrganizationInvitationList({ organizationId });

console.log(response);
/*
{
data: [
_OrganizationInvitation {
id: 'orginv_2b6b8BKxYmCdSNYtEBdk2aQSlyY',
emailAddress: '[email protected]',
role: 'org:member',
organizationId: 'org_2ZUtbk2yvnFGItdeze1ivCh3uqh',
createdAt: 1705538313485,
updatedAt: 1705538313485,
status: 'pending',
publicMetadata: {},
privateMetadata: {}
},
_OrganizationInvitation {
id: 'orginv_2b6SO8VwBMDn2IMYn0xqiaSxVpN',
emailAddress: '[email protected]',
role: 'org:member',
organizationId: 'org_2ZUtbk2yvnFGItdeze1ivCh3uqh',
createdAt: 1705534000014,
updatedAt: 1705534817946,
status: 'revoked',
publicMetadata: {},
privateMetadata: {}
}
],
totalCount: 2
}
*/
```
## Examples

### `getOrganizationInvitationList({ organizationId, status })`
### `getOrganizationInvitationList({ status })`

Retrieves organization invitation list that is filtered by the status of the invitation.

```tsx
const organizationId = 'org_123';
const organizationId = 'my-organization-id';

const { data, totalCount } = await clerkClient.organizations.getOrganizationInvitationList({
const invitations = await clerkClient.organizations.getOrganizationInvitationList({
organizationId,
// returns a list of invitations that have not yet been accepted
status: [ 'pending' ],
});
```

### `getOrganizationInvitationList({ organizationId, limit })`
### `getOrganizationInvitationList({ limit })`

Retrieves organization invitation list that is filtered by the number of results.

```tsx
const organizationId = 'org_123';
const organizationId = 'my-organization-id';

const { data, totalCount } = await clerkClient.organizations.getOrganizationInvitationList({
const invitations = await clerkClient.organizations.getOrganizationInvitationList({
organizationId,
// returns the first 10 results
limit: 10,
});
```

### `getOrganizationInvitationList({ organizationId, offset })`
### `getOrganizationInvitationList({ offset })`

Retrieves organization invitation list that is filtered by the number of results to skip.

```tsx
const organizationId = 'my-organization-id';

const { data, totalCount } = await clerkClient.organizations.getOrganizationInvitationList({
const invitations = await clerkClient.organizations.getOrganizationInvitationList({
organizationId,
// skips the first 10 results
offset: 10,
});
```

## Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint `GET/organizations/{organization_id}/invitations`. See the [BAPI reference](https://clerk.com/docs/reference/backend-api/tag/Organization-Invitations#operation/ListOrganizationInvitations) for more details.
```
4 changes: 2 additions & 2 deletions docs/references/javascript/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ Add the following script to your site's `<body>` element:
<script>
// Get this URL and Publishable Key from the Clerk Dashboard
const clerkPublishableKey = `{{pub_key}}`;
const frontendApiUrl = 'https://[your-domain].clerk.accounts.dev';
const frontendApi = '[your-domain].clerk.accounts.dev';
const version = '@latest'; // Set to appropriate version
// Creates asynchronous script
const script = document.createElement('script');
script.setAttribute('data-clerk-frontend-api', frontendApiUrl);
script.setAttribute('data-clerk-publishable-key', clerkPublishableKey);
script.async = true;
script.src = `${frontendApiUrl}/npm/@clerk/clerk-js${version}/dist/clerk.browser.js`;
script.src = `https://${frontendApiUrl}/npm/@clerk/clerk-js${version}/dist/clerk.browser.js`;
// Adds listener to initialize ClerkJS after it's loaded
script.addEventListener('load', async function () {
Expand Down
6 changes: 1 addition & 5 deletions docs/references/nextjs/auth-middleware.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ description: The `authMiddleware()` method allows you to protect your Next.js ap

# `authMiddleware()`

<Callout type="danger">
This method is now deprecated. Please use [`clerkMiddleware()`](/docs/references/nextjs/clerk-middleware) instead.
</Callout>

The `authMiddleware()` helper integrates Clerk authentication into your Next.js application through middleware. `authMiddleware()` is compatible with both the App and Pages routers.

## Usage
Expand Down Expand Up @@ -251,7 +247,7 @@ The `authMiddleware()` method accepts an optional object. The following options
| Name | Type | Description |
| ---------------------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `afterAuth?` | `function` | Called after the authentication middleware is executed. This function has access to the [`Auth`](/docs/references/nextjs/auth-object) object and can be used to execute logic based on the auth state. |
| `apiRoutes?` | `string[]` | A list of routes that should return 401 if the user is not signed in. You can use glob patterns to match multiple routes or a function to match against the request object. For example: `['/foo', '/bar(.*)']` or `[/^\/foo\/.*$/]` |
| `apiRoutes?` | `string[]` | A list of routes that should return 401 if the user is not logged in. You can use glob patterns to match multiple routes or a function to match against the request object. For example: `['/foo', '/bar(.*)']` or `[/^\/foo\/.*$/]` |
| `audience?` | `string \| string[]` | A string or list of [audiences](https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.3). If passed, it is checked against the `aud` claim in the token. |
| `authorizedParties?` | `string[]` | An allowlist of origins to verify against, to protect your application from the subdomain cookie leaking attack.<br/>For example:<br/>`['http://localhost:3000', 'https://example.com']`<br/>For more information, refer to the [reference guide](/docs/references/nodejs/token-verification#validate-the-authorized-party-of-a-session-token). |
| `beforeAuth?` | `function` | A function called before the authentication middleware is executed. If a redirect response is returned, the middleware will respect it and redirect the user. If `false` is returned, the auth middleware will not execute and the request will be handled as if the auth middleware was not present. |
Expand Down

0 comments on commit c503100

Please sign in to comment.