Skip to content

how to integrate msw in react-router v7? #12651

Closed Answered by elatomo
codenoobforreal asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @codenoobforreal! I just came across your question, and even though it's a bit old, I thought I'd reply for others who might be wondering about this:

You don't need a custom framework. You can simply reveal either your entry.client.tsx file or your entry.server.tsx file, depending on whether you are building an SPA or an SSR app, and what you want to mock. Then, hook up the worker there.

For example, if you are building an SPA, first reveal your entry.client.tsx with react-router reveal entry.client (see React Router Documentation).

You can then update it to start the worker, like in the example below:

import { startTransition, StrictMode } from "react";
import { hydrateRoot } from "re…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@codenoobforreal
Comment options

Answer selected by codenoobforreal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants