@scenarist/nextjs-adapter 0.1.11 → 0.1.13

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 (2) hide show
  1. package/README.md +20 -13
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -64,17 +64,17 @@ This package provides complete Next.js integration for Scenarist's scenario mana
64
64
 
65
65
  ## 📖 Documentation
66
66
 
67
- **Full documentation at [scenarist.io](https://scenarist.io)**
68
-
69
- | Topic | Link |
70
- | ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------- |
71
- | **Why Scenarist?** | [scenarist.io/getting-started/why-scenarist](https://scenarist.io/getting-started/why-scenarist) |
72
- | **Getting Started (App Router)** | [scenarist.io/frameworks/nextjs-app-router/getting-started](https://scenarist.io/frameworks/nextjs-app-router/getting-started) |
73
- | **Getting Started (Pages Router)** | [scenarist.io/frameworks/nextjs-pages-router/getting-started](https://scenarist.io/frameworks/nextjs-pages-router/getting-started) |
74
- | **🎯 React Server Components Guide** | [scenarist.io/frameworks/nextjs-app-router/rsc-guide](https://scenarist.io/frameworks/nextjs-app-router/rsc-guide) |
75
- | **Tool Comparison** | [scenarist.io/comparison](https://scenarist.io/comparison) |
76
- | **Parallel Testing** | [scenarist.io/testing/parallel-testing](https://scenarist.io/testing/parallel-testing) |
77
- | **Testing Philosophy** | [scenarist.io/concepts/philosophy](https://scenarist.io/concepts/philosophy) |
67
+ **Choose your router:**
68
+
69
+ - **→ [App Router Getting Started](https://scenarist.io/frameworks/nextjs-app-router/getting-started)** — Server Components, Route Handlers, Server Actions
70
+ - **→ [Pages Router Getting Started](https://scenarist.io/frameworks/nextjs-pages-router/getting-started)** — API Routes, getServerSideProps, getStaticProps
71
+
72
+ | Topic | Link |
73
+ | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------ |
74
+ | **🎯 React Server Components Guide** | [scenarist.io/frameworks/nextjs-app-router/rsc-guide](https://scenarist.io/frameworks/nextjs-app-router/rsc-guide) |
75
+ | **Why Scenarist?** | [scenarist.io/getting-started/why-scenarist](https://scenarist.io/getting-started/why-scenarist) |
76
+ | **Tool Comparison** | [scenarist.io/comparison](https://scenarist.io/comparison) |
77
+ | **Parallel Testing** | [scenarist.io/testing/parallel-testing](https://scenarist.io/testing/parallel-testing) |
78
78
 
79
79
  ## Core Capabilities
80
80
 
@@ -355,9 +355,16 @@ if (typeof window === "undefined" && scenarist) {
355
355
  > export const scenarist = createScenarist({ enabled: true, scenarios });
356
356
  > ```
357
357
  >
358
- > **Why:** Next.js dev server (and Turbopack) can load the same module multiple times. If you call `createScenarist()` repeatedly, you'll get multiple MSW servers conflicting with each other, causing `[MSW] Multiple handlers with the same URL` warnings and intermittent 500 errors.
358
+ > **Why:** Next.js has a [well-documented singleton problem](https://github.com/vercel/next.js/discussions/68572) where webpack bundles modules multiple times across different chunks, breaking the classic JavaScript singleton pattern. This is compounded by [MSW's process model challenges with Next.js](https://github.com/mswjs/msw/issues/1644)—Next.js keeps multiple Node.js processes that make global module patches difficult to maintain.
359
+ >
360
+ > **Symptoms of this problem:**
361
+ >
362
+ > - `[MSW] Multiple handlers with the same URL pattern` warnings
363
+ > - Intermittent 500 errors during tests
364
+ > - Scenarios not switching properly
365
+ > - Different tests getting wrong scenario responses
359
366
  >
360
- > The singleton pattern inside `createScenarist()` prevents this - but ONLY if you export a constant. Wrapping in a function breaks the singleton protection.
367
+ > **How Scenarist solves this:** The `createScenarist()` function includes built-in singleton protection using `globalThis` guards, ensuring only ONE MSW instance exists even when Next.js duplicates your module. This protection **only works if you export a constant**—wrapping in a function bypasses the singleton guard.
361
368
 
362
369
  ### 3. Create Scenario Endpoint
363
370
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scenarist/nextjs-adapter",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Next.js adapter for Scenarist (Pages Router and App Router)",
5
5
  "author": "Paul Hammond (citypaul) <paul@packsoftware.co.uk>",
6
6
  "license": "MIT",
@@ -59,8 +59,8 @@
59
59
  ],
60
60
  "dependencies": {
61
61
  "zod": "^4.1.13",
62
- "@scenarist/core": "0.1.2",
63
- "@scenarist/msw-adapter": "0.1.2"
62
+ "@scenarist/msw-adapter": "0.1.2",
63
+ "@scenarist/core": "0.1.2"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "msw": "^2.0.0",