node-server icon indicating copy to clipboard operation
node-server copied to clipboard

Bug: Unable to use Hono in Nextjs 14 App Dir with nodejs runtime

Open MathurAditya724 opened this issue 8 months ago • 5 comments

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 - image

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)

MathurAditya724 avatar Jun 09 '24 18:06 MathurAditya724