Skip to content

Commit 4cd4cb9

Browse files
authored
Merge pull request #292 from nicholasoxford/n/updateNext
In the Nextjs integration section, Remove suggestion to put elysia in the top level app folder
2 parents 3223ca3 + c8a0dc2 commit 4cd4cb9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/integrations/nextjs.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ head:
1818

1919
With Nextjs App Router, we can run Elysia on Nextjs route.
2020

21-
1. Create **[[...slugs]]/route.ts** inside app router
21+
1. Create **api/[[...slugs]]/route.ts** inside app router
2222
2. In **route.ts**, create or import an existing Elysia server
2323
3. Export the handler with the name of method you want to expose
2424

2525
```typescript twoslash
2626
// app/[[...slugs]]/route.ts
2727
import { Elysia, t } from 'elysia'
2828

29-
const app = new Elysia()
29+
const app = new Elysia({ prefix: '/api' })
3030
.get('/', () => 'hello Next')
3131
.post('/', ({ body }) => body, {
3232
body: t.Object({
@@ -48,15 +48,15 @@ Please refer to [Nextjs Route Handlers](https://nextjs.org/docs/app/building-you
4848

4949
## Prefix
5050

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.
5252

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.
5454

5555
```typescript twoslash
5656
// app/api/[[...slugs]]/route.ts
5757
import { Elysia, t } from 'elysia'
5858

59-
const app = new Elysia({ prefix: '/api' }) // [!code ++]
59+
const app = new Elysia({ prefix: '/user' }) // [!code ++]
6060
.get('/', () => 'hi')
6161
.post('/', ({ body }) => body, {
6262
body: t.Object({

0 commit comments

Comments
 (0)