Skip to content

Instantly share code, notes, and snippets.

View Yandawl's full-sized avatar

Yandawl

  • England, United Kingdom
  • 01:35 (UTC -12:00)
View GitHub Profile
@Yandawl
Yandawl / MockTrpcProvider.tsx
Last active January 15, 2024 09:12
Implement Mock Service Worker with Storybook to intercept tRPC requests in Next.js 13 (app router)
// Wrap your stories with a tRPC provider.
// However, the msw-trpc package does not currently support request batching.
// Use httpLink instead so that tRPC requests are not batched within stories.
trpc.createClient({
transformer: superjson,
links: [
httpLink({
url: `${getBaseUrl()}/api/trpc`,
headers() {