Skip to content

Commit

Permalink
Add Next.js App Router to readme (#57)
Browse files Browse the repository at this point in the history
* Add Next.js App Router to readme
  • Loading branch information
MatsDK authored Mar 12, 2024
1 parent be69c41 commit 69ff694
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/trpc-playground/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,29 @@ tRPC Playground provides handlers that serve the playground HTML page and handle
<details>
<summary>Next.js</summary>

Next.js App Router

```ts
// src/app/api/trpc-playground/route.ts
import { appRouter } from '@/server'
import { fetchHandler } from 'trpc-playground/handlers/fetch'

const setupHandler = fetchHandler({
router: appRouter,
trpcApiEndpoint: '/api/trpc',
playgroundEndpoint: '/api/trpc-playground',
})

const handler = async (req: Request) => {
const playgroundHandler = await setupHandler
return await playgroundHandler(req)
}

export { handler as GET, handler as POST }
```

Next.js Pages Router

[Example](https://github.com/sachinraja/trpc-playground/tree/main/apps/next)

```ts
Expand Down

0 comments on commit 69ff694

Please sign in to comment.