node-server
node-server copied to clipboard
Bug: Unable to use Hono in Nextjs 14 App Dir with nodejs runtime
Unable to use hono in nextjs app dir with nodejs runtime
Example Code
// app/api/[[...route]]/route.ts
import { Hono } from 'hono'
import { handle } from '@hono/node-server/vercel'
const app = new Hono().basePath('/api')
app.get('/hello', async (c) => {
return c.json({
message: 'Hello Next.js!',
})
})
export const GET = handle(app)
Error -
This code has been recreated from the docs https://hono.dev/getting-started/vercel#node-js for the app dir. It works if we set the runtime to edge
and use the hono/vercel
package like this -
import { Hono } from 'hono'
import { handle } from 'hono/vercel'
export const runtime = "edge"
const app = new Hono().basePath('/api')
app.get('/hello', async (c) => {
return c.json({
message: 'Hello Next.js!',
})
})
export const GET = handle(app)