leerob / hono-vercel-edge-functions

Vercel Edge Functions + Hono Router + Wasm + Rust

Home Page:https://hono-rust-wasm.vercel.app/api/hello

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vercel Edge Functions + Hono Router + Wasm + Rust

This example shows the following:

  1. You are able to write Rust code inside wasm/src
  2. The Rust code gets compiled to WebAssembly
  3. The WebAssembly code is used in an API Route using the Edge Runtime
  4. This API Route can be deployed to Vercel Edge Functions
  5. The Hono Router is used to write all routes in a single API Route

Note: This example is using Next.js "headless" through the local dev server, using next dev to serve API Routes. It's not doing any rendering of pages, so React is not being used. Why? Hono does not currently work with vanilla Vercel Edge Functions, which are served through vercel dev. Hono v3 adds support for Next.js, which enabled me to create this example.

Example

Running Locally

pnpm i
pnpm dev

About

Vercel Edge Functions + Hono Router + Wasm + Rust

https://hono-rust-wasm.vercel.app/api/hello


Languages

Language:TypeScript 87.8%Language:Rust 7.5%Language:JavaScript 4.7%