@@ -18,13 +18,13 @@ 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
26
26
// app/[[...slugs]]/route.ts
27
- const app = new Elysia ()
27
+ const app = new Elysia ({ prefix: ' /api ' } )
28
28
.get (' /' , () => ' hello Next' )
29
29
.post (' /' , ({ body }) => body , {
30
30
body: t .Object ({
@@ -46,13 +46,13 @@ Please refer to [Nextjs Route Handlers](https://nextjs.org/docs/app/building-you
46
46
47
47
## Prefix
48
48
49
- 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.
49
+ Because our Elysia server is not in the root directory of the app router, you need to annotate the prefix to the Elysia server.
50
50
51
- For example, if you place Elysia server in ** app/api /[[ ...slugs]] /route.ts** , you need to annotate prefix as ** /api ** to Elysia server.
51
+ For example, if you place Elysia server in ** app/user /[[ ...slugs]] /route.ts** , you need to annotate prefix as ** /user ** to Elysia server.
52
52
53
53
``` typescript{2}
54
54
// app/api/[[...slugs]]/route.ts
55
- const app = new Elysia({ prefix: '/api ' })
55
+ const app = new Elysia({ prefix: '/user ' })
56
56
.get('/', () => 'hi')
57
57
.post('/', ({ body }) => body, {
58
58
body: t.Object({
0 commit comments