Skip to content

Commit d2614b4

Browse files
docs(nextjs): Add vercel specific microfrontends guide (#15520)
Adds micro frontends guide specific to [vercel's microfrontends feature](https://vercel.com/docs/microfrontends) since it has multi-zone application support which doesn't require the use of module federation. --------- Co-authored-by: Sarah Mischinger <[email protected]>
1 parent 842ce5a commit d2614b4

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

docs/platforms/javascript/common/best-practices/micro-frontends.mdx

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,39 @@ If your app uses micro frontends, it's very useful to be able to track which one
3333

3434
Below you'll find setup instructions for both an automatic and a manual way to route errors to different Sentry projects.
3535

36+
<PlatformSection supported={["javascript.nextjs"]}>
37+
38+
## Vercel Multi-Zone Micro Frontends
39+
40+
Vercel's multi-zone applications let you slice a large app into smaller, independently managed projects. Each project operates as its own application, with its own UI and tech stack. For example, you might use Next.js for one project, SvelteKit for another, and React for a third.
41+
42+
To set up Sentry in a multi-zone setup, configure Sentry separately within each project. Follow the installation steps for the framework each project uses. Here are a few examples:
43+
44+
- **[Next.js](/platforms/javascript/guides/nextjs/)**
45+
- **[React](/platforms/javascript/guides/react/)**
46+
- **[SvelteKit](/platforms/javascript/guides/sveltekit/)**
47+
48+
We recommend using a different DSN for each project. This makes it easier to
49+
identify which project errors are coming from, helping you track issues and
50+
fix them faster in complex frontend architectures.
51+
52+
<Alert>
53+
With the exception of Vercel multi-zone micro frontends, you should call
54+
`Sentry.init()` only once in your application. Initializing Sentry multiple
55+
times can lead to unexpected behavior.
56+
</Alert>
57+
58+
</PlatformSection>
59+
60+
<PlatformSection notSupported={["javascript.nextjs"]}>
61+
3662
<Alert>
3763
In all cases `Sentry.init()` must never be called more than once, doing so
3864
will result in undefined behavior.
3965
</Alert>
4066

67+
</PlatformSection>
68+
4169
## Automatically Route Errors to Different Projects
4270

4371
`ModuleMetadata` and `makeMultiplexedTransport` can be used together to automatically route events to specific Sentry projects that represent your micro frontend services. Events will be routed once the service where the error occurred has been identified, ensuring errors are tracked in the correct project.
@@ -75,7 +103,8 @@ module.exports = {
75103
```
76104

77105
<Alert>
78-
**Replace `__MODULE_DSN__` with your actual Sentry project DSN.** You can find your DSN in your Sentry project settings under Client Keys (DSN).
106+
**Replace `__MODULE_DSN__` with your actual Sentry project DSN.** You can find
107+
your DSN in your Sentry project settings under Client Keys (DSN).
79108
</Alert>
80109

81110
Once metadata has been injected into modules, the `moduleMetadataIntegration`
@@ -203,7 +232,9 @@ init({
203232
```
204233
205234
<Alert>
206-
**Replace `__DEFAULT_DSN__` with your actual Sentry project DSN.** This should be the DSN for your default/fallback Sentry project. You can find your DSN in your Sentry project settings under Client Keys (DSN).
235+
**Replace `__DEFAULT_DSN__` with your actual Sentry project DSN.** This should
236+
be the DSN for your default/fallback Sentry project. You can find your DSN in
237+
your Sentry project settings under Client Keys (DSN).
207238
</Alert>
208239
209240
Once this is set up, errors - both handled and unhandled - will be automatically routed to the right project.
@@ -257,7 +288,8 @@ init({
257288
- Replace `__CART_DSN__` with the DSN for your cart micro frontend's Sentry project
258289
- Replace `__GALLERY_DSN__` with the DSN for your gallery micro frontend's Sentry project
259290
260-
You can find your DSNs in each Sentry project's settings under Client Keys (DSN).
291+
You can find your DSNs in each Sentry project's settings under Client Keys (DSN).
292+
261293
</Alert>
262294
263295
You can then set tags/contexts on events in individual micro-frontends to decide which Sentry project to send the event to as follows:

docs/platforms/javascript/guides/nextjs/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ Our next recommended steps for you are:
217217
- Learn how to [manually capture errors](/platforms/javascript/guides/nextjs/usage/)
218218
- Continue to [customize your configuration](/platforms/javascript/guides/nextjs/configuration/)
219219
- Get familiar with [Sentry's product features](/product) like tracing, insights, and alerts
220+
- Learn how to [set up Sentry for Vercel's micro frontends](/platforms/javascript/guides/nextjs/best-practices/micro-frontends/)
220221
- Learn more about our [Vercel integration](/organization/integrations/deployment/vercel/)
221222

222223
<Expandable permalink={false} title="Are you having problems setting up the SDK?">

0 commit comments

Comments
 (0)