Skip to content

Commit feb4f72

Browse files
feat(docs): document satelliteAutoSync option for satellite domains (#2998)
Co-authored-by: Sarah Soutoul <sarah@clerk.dev>
1 parent 10cfbe8 commit feb4f72

File tree

5 files changed

+74
-8
lines changed

5 files changed

+74
-8
lines changed

docs/_partials/clerk-middleware-options.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ The `clerkMiddleware()` function accepts an optional object. The following optio
3636

3737
---
3838

39+
- `satelliteAutoSync?`
40+
- `boolean`
41+
42+
<Include src="_partials/satellite-auto-sync-description" />
43+
44+
---
45+
3946
- `jwtKey`
4047
- `string`
4148

docs/_partials/clerk-options.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@
3434

3535
---
3636

37+
- `satelliteAutoSync?`
38+
- `boolean`
39+
40+
<Include src="_partials/satellite-auto-sync-description" />
41+
42+
---
43+
3744
- `proxyUrl?`
3845
- `string`
3946

docs/_partials/clerk-provider/properties.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@
8585

8686
---
8787

88+
- `satelliteAutoSync?`
89+
- `boolean`
90+
91+
<Include src="_partials/satellite-auto-sync-description" />
92+
93+
---
94+
8895
- `localization`
8996
- <code>[Localization](/docs/guides/customizing-clerk/localization) | undefined</code>
9097

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Controls whether a satellite app automatically syncs authentication state with the primary domain on first page load. When `false` (default), the satellite app skips the automatic redirect if no session cookies exist, and only triggers the handshake after the user initiates a sign-in or sign-up action. When `true`, the satellite app redirects to the primary domain on every first visit to sync state. Defaults to `false`. See [satellite domains](/docs/guides/dashboard/dns-domains/satellite-domains) for more details.

docs/guides/dashboard/dns-domains/satellite-domains.mdx

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,21 @@ Your "primary" domain is where the authentication state lives, and satellite dom
2727

2828
Users must complete both the sign-in and sign-up flows on the primary domain by using the [`<SignIn />`](/docs/reference/components/authentication/sign-in) component or [`useSignIn()`](/docs/reference/hooks/use-sign-in) hook for sign-in and [`<SignUp />`](/docs/reference/components/authentication/sign-up) component or [`useSignUp()`](/docs/reference/hooks/use-sign-up) hook for sign-up.
2929

30-
To access authentication state from a satellite domain, users will be transparently redirected to the primary domain. If users need to sign in, they must be redirected to a sign in flow hosted on the primary domain, then redirected back to the originating satellite domain. The same redirection process applies to sign-up flows.
30+
### How authentication syncing works
31+
32+
> [!CAUTION]
33+
> If you are upgrading from Core 2, see the [migration section](#migrating-from-core-2) for behavior changes that may affect your satellite applications.
34+
35+
The syncing behavior between satellite and primary domains is controlled by the `satelliteAutoSync` option.
36+
37+
With `satelliteAutoSync: false` (the default), satellite domains do not automatically sync authentication state with the primary domain when a user visits the page. This means there is no upfront performance cost for users visiting a satellite domain. Authentication state is only synced when a user initiates a sign-in or sign-up action:
38+
39+
1. When a user selects "Sign in" on the satellite domain, they are redirected to the primary domain.
40+
1. If the user is already signed in on the primary domain, they are immediately redirected back to the satellite domain with the existing auth state — no additional user action is required.
41+
1. If the user is not signed in on the primary domain, they complete the sign-in (or sign-up) flow there and are then redirected back to the satellite domain.
42+
1. After the initial sync, signing out from either domain signs out from all domains.
43+
44+
If you set `satelliteAutoSync: true`, the satellite domain will automatically redirect to the primary domain on first load to sync authentication state, even if the user has no session. This matches the original Core 2 behavior and is useful if you want users who are already signed in on the primary domain to be automatically recognized on the satellite without needing to select "Sign in". However, this comes with a performance cost since every first visit triggers a redirect.
3145

3246
## How to add satellite domains
3347

@@ -37,7 +51,7 @@ To access authentication state from a satellite domain, users will be transparen
3751
### Create your application and install Clerk
3852

3953
> [!WARNING]
40-
> Currently, multi-domain can be added to any Next.js or Remix application. For other React frameworks, multi-domain is still supported as long as you do not use server rendering or hydration.
54+
> Currently, multi-domain can be added to any Next.js, TanStack Start, or Nuxt application. For other React frameworks, multi-domain is still supported as long as you do not use server rendering or hydration.
4155
4256
To get started, you need to create an application from the [Clerk Dashboard](https://dashboard.clerk.com/). Once you create an instance via the Clerk Dashboard, you will be prompted to choose a domain. This is your primary domain. For the purposes of this guide:
4357

@@ -331,6 +345,10 @@ To access authentication state from a satellite domain, users will be transparen
331345
domain: 'https://satellite.dev',
332346
// Or, in development:
333347
// domain: 'http://localhost:3001',
348+
349+
// Uncomment to automatically sync auth state on first load.
350+
// This will add a redirect on first visit, which comes with a performance cost since every first visit triggers a redirect.
351+
// satelliteAutoSync: true,
334352
}
335353

336354
export default clerkMiddleware(async (auth, req) => {
@@ -421,17 +439,43 @@ To access authentication state from a satellite domain, users will be transparen
421439
</Tab>
422440
</Tabs>
423441

424-
### Ready to go 🎉
442+
### Ready to go
425443

426444
Your satellite application should now be able to access the authentication state from your satellite domain!
427445

428-
You can see it in action by:
429-
430-
1. Visiting the primary domain and signing in.
431-
1. Visiting the satellite domain.
432-
1. You now have an active session in the satellite domain, so you can see the [`<UserProfile />`](/docs/reference/components/user/user-profile) component and update your information.
446+
To verify it's working, visit your satellite domain and select "Sign in" — you should be redirected to the primary domain and back with an active session. For details on the sync flow, see the [How authentication syncing works](#how-authentication-syncing-works) section.
433447

434448
You can repeat this process and create as many satellite applications as you need.
435449
</Steps>
436450

451+
## Migrating from Core 2
452+
453+
In Core 2, satellite applications automatically synced authentication state with the primary domain on every first page load by redirecting users to the primary domain and back. This happened regardless of whether the user had an active session, which caused unnecessary latency for apps where most visitors are anonymous.
454+
455+
In Core 3, this behavior is controlled by the `satelliteAutoSync` option, which defaults to `false`. This means satellite apps no longer perform automatic redirects on first visit.
456+
457+
### What changed
458+
459+
| | Core 2 | Core 3 (default) |
460+
| - | - | - |
461+
| First visit to satellite | Redirects to primary domain to sync state, then back | No redirect, page loads immediately |
462+
| Sign-in flow | Same as Core 3 | User selects "Sign in" → redirected to primary → signs in → redirected back |
463+
| Already signed in on primary | Automatically synced on first visit | Only synced after user selects "Sign in" (redirect is instant, no user action needed) |
464+
| Sign-out | Signs out from all domains | Signs out from all domains |
465+
| Performance | Redirect on every first visit | No upfront cost |
466+
467+
### To preserve Core 2 behavior
468+
469+
If your application relies on users being automatically recognized on the satellite domain without selecting "Sign in", set `satelliteAutoSync` to `true`:
470+
471+
```ts {{ prettier: false }}
472+
// In your middleware options or ClerkProvider props
473+
{
474+
isSatellite: true,
475+
domain: 'satellite.dev',
476+
signInUrl: 'https://primary.dev/sign-in',
477+
satelliteAutoSync: true, // Opt-in to automatic sync on first load
478+
}
479+
```
480+
437481
If you have any questions about satellite domains, or you're having any trouble setting this up, contact [support@clerk.com](mailto:support@clerk.com)

0 commit comments

Comments
 (0)