Repository: vercel/next.js
Pull request: Fix/msw-issue-68521

### Fix: [68521](https://github.com/vercel/next.js/issues/68521) Updating outdated with-msw example
The [with-msw](https://github.com/vercel/next.js/tree/canary/examples/with-msw) is outdated and doesn't work with the latest msw version.

### What?
The [with-msw](https://github.com/vercel/next.js/tree/canary/examples/with-msw) example is outdated and does not work with the latest msw version. 

### Why?
- msw now uses http instead of rest and the outdated implementation does not work with the latest version anymore. 
- the client-side worker is now imported through msw/browser.

### How?
- replaced all usage of rest with http to align with MSW's new API.
- updated the worker import to use msw/browser as per the new structure.

### Media
https://github.com/user-attachments/assets/ab9ebb49-28b2-4095-aeea-dcd301093c9f

Changed files:
filename: examples/with-msw/mocks/browser.ts
patch: @@ -1,4 +1,4 @@
-import { setupWorker } from "msw";
+import { setupWorker } from "msw/browser";
 import { handlers } from "./handlers";
 
 export const worker = setupWorker(...handlers);

filename: examples/with-msw/mocks/handlers.ts
patch: @@ -1,26 +1,25 @@
-import { rest } from "msw";
+import { http, HttpResponse } from "msw";
 import { Book, Review } from "./types";
 
 export const handlers = [
-  rest.get("https://my.backend/book", (_req, res, ctx) => {
-    return res(
-      ctx.json<Book>({
-        title: "Lord of the Rings",
-        imageUrl: "/book-cover.jpg",
-        description:
-          "The Lord of the Rings is an epic high-fantasy novel written by English author and scholar J. R. R. Tolkien.",
-      }),
-    );
+  http.get("https://my.backend/book", () => {
+    const book: Book = {
+      title: "Lord of the Rings",
+      imageUrl: "/book-cover.jpg",
+      description:
+        "The Lord of the Rings is an epic high-fantasy novel written by English author and scholar J. R. R. Tolkien.",
+    };
+    return HttpResponse.json(book);
   }),
-  rest.get("/reviews", (_req, res, ctx) => {
-    return res(
-      ctx.json<Review[]>([
-        {
-          id: "60333292-7ca1-4361-bf38-b6b43b90cb16",
-          author: "John Maverick",
-          text: "Lord of The Rings, is with no absolute hesitation, my most favored and adored book by‑far. The trilogy is wonderful‑ and I really consider this a legendary fantasy series. It will always keep you at the edge of your seat‑ and the characters you will grow and fall in love with!",
-        },
-      ]),
-    );
+
+  http.get("/reviews", () => {
+    const reviews: Review[] = [
+      {
+        id: "60333292-7ca1-4361-bf38-b6b43b90cb16",
+        author: "John Maverick",
+        text: "Lord of The Rings, is with no absolute hesitation, my most favored and adored book by‑far. The trilogy is wonderful‑ and I really consider this a legendary fantasy series. It will always keep you at the edge of your seat‑ and the characters you will grow and fall in love with!",
+      },
+    ];
+    return HttpResponse.json(reviews);
   }),
 ];

filename: examples/with-msw/package.json
patch: @@ -6,7 +6,7 @@
     "start": "next start"
   },
   "dependencies": {
-    "msw": "^0.49.0",
+    "msw": "^2.11.1",
     "next": "latest",
     "react": "^18.2.0",
     "react-dom": "^18.2.0"