跳转到内容

此内容尚不支持你的语言。

此内容尚不支持你的语言。

Integration with Netlify Edge Function

Netlify Edge Functions run on Deno, which is one of Elysia’s supported runtimes, as Elysia is built on top of Web Standards.

Netlify Edge Functions require a special directory to run a function; the default is <directory>/netlify/edge-functions.

To create a function at /hello, you would need to create a file at netlify/edge-functions/hello.ts, then export a function that forwards the request to Elysia.

netlify/edge-functions/hello.ts
import { Elysia } from 'elysia'
export const config = { path: '/hello' }
const app = new Elysia({ prefix: '/hello' })
.get('/', () => 'Hello Elysia')
export default (request: Request) => app.handle(request)

To test your Elysia server on Netlify Edge Functions locally, you can install the Netlify CLI to simulate function invocation.

To install the Netlify CLI:

Terminal window
bun add -g netlify-cli

To run the development environment:

Terminal window
netlify dev

For additional information, please refer to the Netlify Edge Functions documentation.

If your pnpm configuration does not install peer dependencies, add the peers required by Elysia v2 explicitly:

Terminal window
pnpm add typebox exact-mirror openapi-types
编辑此页

最近更新:

Type to search the documentation.

    Up arrowDown arrow to navigateEnter to selectEscape to close