-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add organizationSyncOptions prop to clerkMiddleware() options #1634
base: main
Are you sure you want to change the base?
Add organizationSyncOptions prop to clerkMiddleware() options #1634
Conversation
- `signInUrl?` | ||
- `publishableKey` | ||
- `string` | ||
|
||
An alternative sign in URL. | ||
The Clerk publishable key for your instance. This can be found in your Clerk Dashboard on the **[API Keys](https://dashboard.clerk.com/last-active?path=api-keys)** page. | ||
|
||
--- | ||
|
||
- `signUpUrl?` | ||
- `secretKey?` | ||
- `string` | ||
|
||
An alternative sign up URL. | ||
The Clerk secret key for your instance. This can be found in your Clerk Dashboard on the **[API Keys](https://dashboard.clerk.com/last-active?path=api-keys)** page. The `CLERK_ENCRYPTION_KEY` environment variable must be set when providing `secretKey` as an option, refer to [Dynamic keys](#dynamic-keys). | ||
|
||
--- | ||
|
||
- `publishableKey` | ||
- `signInUrl?` | ||
- `string` | ||
|
||
The Clerk publishable key for your instance. This can be found in your Clerk Dashboard on the **[API Keys](https://dashboard.clerk.com/last-active?path=api-keys)** page. | ||
An alternative sign in URL. | ||
|
||
--- | ||
|
||
- `secretKey?` | ||
- `signUpUrl?` | ||
- `string` | ||
|
||
The Clerk secret key for your instance. This can be found in your Clerk Dashboard on the **[API Keys](https://dashboard.clerk.com/last-active?path=api-keys)** page. The `CLERK_ENCRYPTION_KEY` environment variable must be set when providing `secretKey` as an option, refer to [Dynamic keys](#dynamic-keys). | ||
An alternative sign up URL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all just a re-arrangement - I noticed that the list was almost alphabetized, and now it's alphabetized.
URL patterns that are organization-specific and contain an organization ID or slug as a path parameter. If a request | ||
matches this path, the organization identifier will be extracted and activated before rendering. | ||
|
||
If the route also matches the personalAccountPatterns, this takes precedence. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 Can we have personalAccountPatterns
appear with in-line code formatting, or even link to the definition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> no change will be made to the previously active organization. Components must detect this case and respond with an | ||
> appropriate error (e. g., `notFound()`, an | ||
> [organization switcher](/docs/components/organization/organization-switcher), etc.). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 This sentence and examples in parentheses was confusing to me, because responding by rendering the org switcher doesn't seem to fall into the category of an appropriate error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does that feel?
Common examples: | ||
- `["/orgs/:slug", "/orgs/:slug/(.*)"]` | ||
- `["/orgs/:id", "/orgs/:id/(.*)"]` | ||
- `["/app/:any/orgs/:slug", "/app/:any/orgs/:slug/(.*)"]` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Would it be helpful to provide some examples that would match these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I just saw the section on Patterns, so maybe this isn't as necessary
Hey, here’s your docs preview: https://clerk.com/docs/pr/1634 |
Co-authored-by: Mary Zhong <[email protected]>
It causes our linter to fail: https://github.com/clerk/clerk-docs/actions/runs/11462466478/job/31893925923?pr=1634 it'd be nice if the linter allowed for glossary links, but i'm not going to move that boulder today.
Co-authored-by: victoria <[email protected]>
b273bfa
to
7c750bc
Compare
Co-authored-by: victoria <[email protected]>
Co-authored-by: victoria <[email protected]>
Thank you @victoriaxyz for those improvements! |
Co-authored-by: victoria <[email protected]>
Co-authored-by: victoria <[email protected]>
Co-authored-by: victoria <[email protected]>
Co-authored-by: victoria <[email protected]>
Co-authored-by: victoria <[email protected]>
Co-authored-by: victoria <[email protected]>
This reverts commit 0220928. Decided that we like the personal account highlight. Here's my justification for any future readers who are interested In general, our section links are quite good - the section title we link to makes it clear that the article is talking about the term of interest. In this case, we don't have a "personal account" definition to jump to with a section link. As a user, if I was promised the definition of Personal Account and the link went to https://clerk.com/docs/organizations/organization-workspaces#organization-workspaces-in-the-clerk-dashboard, there's a good chance i'd read the long title and think "ugh, I don't want to read up on the complete theory of organization workspaces in the dashboard right now thank you", and navigate away. I think the text highlight would point me to the part i'm actually interested in! It's a little bit brittle though - if we restructure the page in the future so that the first appearance of "Personal account" isn't the definition, this will seem broken. Tradeoffs! I think it's worth it in this case, but not a big deal either way.
This reverts commit e9ff7c3. We like the test highlighting after all. My justification for anyone interested: In general, our section links are quite good - the section title we link to makes it clear that the article is talking about the term of interest. In this case, we don't have a "personal account" definition to jump to with a section link. As a user, if I was promised the definition of Personal Account and the link went to https://clerk.com/docs/organizations/organization-workspaces#organization-workspaces-in-the-clerk-dashboard, there's a good chance i'd read the long title and think "ugh, I don't want to read up on the complete theory of organization workspaces in the dashboard right now thank you", and navigate away. I think the text highlight would point me to the part i'm actually interested in! It's a little bit brittle though - if we restructure the page in the future so that the first appearance of "Personal account" isn't the definition, this will seem broken. Tradeoffs! I think it's worth it in this case, but not a big deal either way.
After actually digesting https://clerk.com/docs/organizations/organization-workspaces#organization-workspaces-in-the-clerk-dashboard, i think that's probably not the best thing to link to! The use-case i'm talking to isn't about the dashboard at all - it's building custom apps. The dashboard happens to consume this feature also, so it has "personal accounts", but those docs are specifically about what personal accounts mean to the dashboard, not to any application.
- `organizationSyncOptions?` | ||
- <code>[OrganizationSyncOptions](#organization-sync-options) | undefined</code> | ||
|
||
Used to activate a specific [organization](docs/organizations/overview) or [personal account](https://clerk.com/glossary#personal-account) based on URL path parameters. If there's a mismatch between the active organization in the session (e.g., as reported by [`auth()`](/docs/references/nextjs/auth)) and the organization indicated by the URL, the middleware will attempt to activate the organization specified in the URL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used to activate a specific [organization](docs/organizations/overview) or [personal account](https://clerk.com/glossary#personal-account) based on URL path parameters. If there's a mismatch between the active organization in the session (e.g., as reported by [`auth()`](/docs/references/nextjs/auth)) and the organization indicated by the URL, the middleware will attempt to activate the organization specified in the URL. | |
Used to activate a specific [organization](docs/organizations/overview) or [personal account](/docs/organizations/organization-workspaces#organization-workspaces-in-the-clerk-dashboard:~:text=Personal%20account) based on URL path parameters. If there's a mismatch between the active organization in the session (e.g., as reported by [`auth()`](/docs/references/nextjs/auth)) and the organization indicated by the URL, the middleware will attempt to activate the organization specified in the URL. |
- `string` | ||
|
||
An alternative sign up URL. | ||
The Clerk secret key for your instance. This can be found in your Clerk Dashboard on the **[API Keys](https://dashboard.clerk.com/last-active?path=api-keys)** page. The `CLERK_ENCRYPTION_KEY` environment variable must be set when providing `secretKey` as an option. For more information, refer to [Dynamic keys](#dynamic-keys) section. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Clerk secret key for your instance. This can be found in your Clerk Dashboard on the **[API Keys](https://dashboard.clerk.com/last-active?path=api-keys)** page. The `CLERK_ENCRYPTION_KEY` environment variable must be set when providing `secretKey` as an option. For more information, refer to [Dynamic keys](#dynamic-keys) section. | |
The Clerk secret key for your instance. This can be found in your Clerk Dashboard on the **[API Keys](https://dashboard.clerk.com/last-active?path=api-keys)** page. The `CLERK_ENCRYPTION_KEY` environment variable must be set when providing `secretKey` as an option. For more information, refer to the [Dynamic keys](#dynamic-keys) section. |
Patterns must have a path parameter named either `:id` (to match a Clerk organization ID) or `:slug` (to match a Clerk organization slug). | ||
|
||
> [!WARNING] | ||
> If the organization can't be activated—either because it doesn't exist or the user lacks access—the previously active organization will remain unchanged. Components must detect this case and provide an appropriate error and/or resolution pathway, such as calling `notFound()` or displaying an [organization switcher](/docs/components/organization/organization-switcher). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> If the organization can't be activated—either because it doesn't exist or the user lacks access—the previously active organization will remain unchanged. Components must detect this case and provide an appropriate error and/or resolution pathway, such as calling `notFound()` or displaying an [organization switcher](/docs/components/organization/organization-switcher). | |
> If the organization can't be activated—either because it doesn't exist or the user lacks access—the previously active organization will remain unchanged. Components must detect this case and provide an appropriate error and/or resolution pathway, such as calling `notFound()` or displaying an [`<OrganizationSwitcher />`](/docs/components/organization/organization-switcher). |
- <code>[Pattern](#pattern)\[]</code> | ||
|
||
Specifies URL patterns that are organization-specific, containing an organization ID or slug as a path parameter. If a request | ||
matches this path, the organization identifier will be extracted and activated before rendering. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when you say "the organization identifier will be activated", do you mean the organization identifier will be used to set that org as active?
- `personalAccountPatterns` | ||
- <code>[Pattern](#pattern)\[]</code> | ||
|
||
URL patterns for resources that exist within the context of a [Clerk Personal Account](https://clerk.com/glossary#personal-account) (user-specific, outside any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URL patterns for resources that exist within the context of a [Clerk Personal Account](https://clerk.com/glossary#personal-account) (user-specific, outside any | |
URL patterns for resources that exist within the context of a [Clerk Personal Account](/docs/organizations/organization-workspaces#organization-workspaces-in-the-clerk-dashboard:~:text=Personal%20account) (user-specific, outside any |
Depends on the release of clerk/javascript#4320
Preview
https://clerk.com/docs/pr/1634/references/nextjs/clerk-middleware#clerk-middleware-next-js
What changed?
This PR documents a new middleware option introduced in clerk/javascript#3977
What's next?