Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Next.js App Router to readme #57

Merged
merged 5 commits into from
Mar 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading