osrv 0.5.0 copy "osrv: ^0.5.0" to clipboard
osrv: ^0.5.0 copied to clipboard

Unified Dart server runtime for Dart, Node, Bun, Deno, Cloudflare, Vercel, and Netlify.

example/README.md

Example #

This directory contains minimal runnable examples for the officially supported osrv runtime families.

Included entries:

  • dart.dart
  • node.dart
  • bun.dart
  • deno.dart
  • cloudflare.dart
  • vercel.dart
  • netlify.dart

All entries share the same server.dart definition. That server only returns:

Hello Osrv!

Dart Runtime #

Run the Dart-hosted example directly from the package root:

dart run example/dart.dart

Node, Bun, and Deno Runtimes #

The node, bun, and deno examples must run on their target JavaScript hosts.

Compile them first:

dart compile js example/node.dart -o example/node.dart.js
dart compile js example/bun.dart -o example/bun.dart.js
dart compile js example/deno.dart -o example/deno.dart.js

Then run them with their matching hosts:

node example/node.dart.js
bun example/bun.dart.js
deno run --allow-net example/deno.dart.js

Fetch-Export Hosts #

Compile the entry to JavaScript, then use the matching shim:

dart compile js example/cloudflare.dart -o example/cloudflare.dart.js
mkdir -p example/api
dart compile js example/vercel.dart -o example/api/index.dart.js
mkdir -p example/netlify/functions
dart compile js example/netlify.dart -o example/netlify/functions/index.dart.js

The JavaScript shims are:

Cloudflare Worker Example #

This directory also includes:

Use them from inside example/:

npm install
npm run build:cloudflare
npm run dev:cloudflare

Vercel Function Example #

This directory also includes:

Use them from inside example/:

npm install
npm run build:vercel
vercel dev

api/index.mjs sets globalThis.self before loading the compiled Dart module. That bootstrap must happen in JavaScript; doing it from Dart interop is too late.

Netlify Function Example #

This directory also includes:

Build the Dart bundle from inside example/:

npm run build:netlify

Then serve it with the Netlify CLI if you have it installed:

netlify dev
5
likes
160
points
474
downloads

Documentation

Documentation
API reference

Publisher

verified publishermedz.dev

Weekly Downloads

Unified Dart server runtime for Dart, Node, Bun, Deno, Cloudflare, Vercel, and Netlify.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

ht, web

More

Packages that depend on osrv