Skip to content

Commit 895294e

Browse files
authored
Merge pull request #260 from ravvi-kumar/patch-1
fix : changes according to new nextjs doc & fix typo
2 parents e3a8e93 + b2b7948 commit 895294e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

docs/integrations/nextjs.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ 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 **[[...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
26-
// apps/[...slugs]/routes.ts
26+
// app/[[...slugs]]/route.ts
2727
const app = new Elysia()
2828
.get('/', () => 'hello Next')
2929
.post('/', ({ body }) => body, {
@@ -45,12 +45,13 @@ With this approach, you can have co-location of both frontend and backend in a s
4545
Please refer to [Nextjs Route Handlers](https://nextjs.org/docs/app/building-your-application/routing/route-handlers#static-route-handlers) for more information.
4646

4747
## Prefix
48+
4849
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.
4950

50-
For example, if you place Elysia server in **apps/api/[...slugs]/routes.ts**, you need to annotate prefix as **/api** to Elysia server.
51+
For example, if you place Elysia server in **app/api/[[...slugs]]/route.ts**, you need to annotate prefix as **/api** to Elysia server.
5152

52-
```typescript
53-
// apps/api/[...slugs]/routes.ts
53+
```typescript{2}
54+
// app/api/[[...slugs]]/route.ts
5455
const app = new Elysia({ prefix: '/api' })
5556
.get('/', () => 'hi')
5657
.post('/', ({ body }) => body, {

0 commit comments

Comments
 (0)