File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,29 @@ tRPC Playground provides handlers that serve the playground HTML page and handle
17
17
<details >
18
18
<summary >Next.js</summary >
19
19
20
+ Next.js App Router
21
+
22
+ ``` ts
23
+ // src/app/api/trpc-playground/route.ts
24
+ import { appRouter } from ' @/server'
25
+ import { fetchHandler } from ' trpc-playground/handlers/fetch'
26
+
27
+ const setupHandler = fetchHandler ({
28
+ router: appRouter ,
29
+ trpcApiEndpoint: ' /api/trpc' ,
30
+ playgroundEndpoint: ' /api/trpc-playground' ,
31
+ })
32
+
33
+ const handler = async (req : Request ) => {
34
+ const playgroundHandler = await setupHandler
35
+ return await playgroundHandler (req )
36
+ }
37
+
38
+ export { handler as GET , handler as POST }
39
+ ```
40
+
41
+ Next.js Pages Router
42
+
20
43
[ Example] ( https://github.com/sachinraja/trpc-playground/tree/main/apps/next )
21
44
22
45
``` ts
You can’t perform that action at this time.
0 commit comments