Skip to content
Avatar of preactjspreactjs/preact-on-the-edge

Preact on the Edge

Server-rendered Preact using Vercel Edge Functions.

Framework
CSS
Preact on the Edge

Preact on the Edge

react-on-the-edge but on top of Preact. It uses esbuild for bundling and Vercel Edge Functions for SSR.

This example is for framework builders and advanced usage of the low-level Vercel Build Output API. If you're looking to develop a Preact application with dynamic Edge capabilities, we recommend Next.js Middleware and Vercel Edge Functions, with preact/compat.

How to use

Run pnpm i then:

  • To build: pnpm build
  • To run a local server: pnpm start

After building, .vercel/output will be created which you can deploy via vc --prebuilt.

Architecture

  • util/build.mjs implements the build process on top of esbuild that bundles src/app into an Edge Function.
  • util/start.mjs implements a local server using the edge-runtime package that can locally run the build outputs.

Developing

Due to the absence of a dev server, watchexec can be used as a replacement. Use brew install watchexec to install.

watchexec -c -r --no-meta 'node util/build.mjs; node util/start.mjs'
Preact on the Edge
Avatar of preactjspreactjs/preact-on-the-edge

Preact on the Edge

Server-rendered Preact using Vercel Edge Functions.

Framework
CSS

Preact on the Edge

react-on-the-edge but on top of Preact. It uses esbuild for bundling and Vercel Edge Functions for SSR.

This example is for framework builders and advanced usage of the low-level Vercel Build Output API. If you're looking to develop a Preact application with dynamic Edge capabilities, we recommend Next.js Middleware and Vercel Edge Functions, with preact/compat.

How to use

Run pnpm i then:

  • To build: pnpm build
  • To run a local server: pnpm start

After building, .vercel/output will be created which you can deploy via vc --prebuilt.

Architecture

  • util/build.mjs implements the build process on top of esbuild that bundles src/app into an Edge Function.
  • util/start.mjs implements a local server using the edge-runtime package that can locally run the build outputs.

Developing

Due to the absence of a dev server, watchexec can be used as a replacement. Use brew install watchexec to install.

watchexec -c -r --no-meta 'node util/build.mjs; node util/start.mjs'

Unleash New Possibilities

Deploy your app on Vercel and unlock its full potential