@@ -18,15 +18,15 @@ head:
18
18
19
19
With Nextjs App Router, we can run Elysia on Nextjs route.
20
20
21
- 1 . Create ** [[ ...slugs]] /route.ts** inside app router
21
+ 1 . Create ** api/ [[ ...slugs]] /route.ts** inside app router
22
22
2 . In ** route.ts** , create or import an existing Elysia server
23
23
3 . Export the handler with the name of method you want to expose
24
24
25
25
``` typescript twoslash
26
26
// app/[[...slugs]]/route.ts
27
27
import { Elysia , t } from ' elysia'
28
28
29
- const app = new Elysia ()
29
+ const app = new Elysia ({ prefix: ' /api ' } )
30
30
.get (' /' , () => ' hello Next' )
31
31
.post (' /' , ({ body }) => body , {
32
32
body: t .Object ({
@@ -48,15 +48,15 @@ Please refer to [Nextjs Route Handlers](https://nextjs.org/docs/app/building-you
48
48
49
49
## Prefix
50
50
51
- If you place an Elysia server not in the root directory of the app router, you need to annotate the prefix to the Elysia server.
51
+ Because our Elysia server is not in the root directory of the app router, you need to annotate the prefix to the Elysia server.
52
52
53
- For example, if you place Elysia server in ** app/api /[[ ...slugs]] /route.ts** , you need to annotate prefix as ** /api ** to Elysia server.
53
+ For example, if you place Elysia server in ** app/user /[[ ...slugs]] /route.ts** , you need to annotate prefix as ** /user ** to Elysia server.
54
54
55
55
``` typescript twoslash
56
56
// app/api/[[...slugs]]/route.ts
57
57
import { Elysia , t } from ' elysia'
58
58
59
- const app = new Elysia ({ prefix: ' /api ' }) // [!code ++]
59
+ const app = new Elysia ({ prefix: ' /user ' }) // [!code ++]
60
60
.get (' /' , () => ' hi' )
61
61
.post (' /' , ({ body }) => body , {
62
62
body: t .Object ({
0 commit comments