4.2 - islands that stream

Weave appsAPIssitesedge workers
from one thread of TypeScript.

Server and client live in the same file; weft splits them at build time and sends the browser only what it runs. No config file, no API layer to keep in sync, a 9.4 KB runtime.

bun create weft@latest Try it here
  • MIT licensed
  • 1,240 contributors
  • 2.1M installs a week

No config file. Really.weft.config.ts is optional - most apps never write one.

// trusted by

Teams who ship on weft

// why weft

One file, two runtimes, no glue.

Most of a web app is the code that moves data between a server and a browser. Weft writes that code for you.

  • Server and client in the same file

    A server() function runs on the server, everywhere else runs in the browser - weft cuts the file in two and types the call between them.

    const add = server(async (text: string) => db.todos.insert({ text }));
     
    export default function Todos() {
      return <form action={add}><input name="text" /></form>;
    }
  • A runtime you can read

    The whole client runtime is 9.4 KB compressed - smaller than most hero images.

    See the numbers

  • Islands that stream

    Each interactive part ships and wakes up on its own, as its data arrives - the page never waits for the slowest.

  • Routes you can type

    The file tree is the router; links are checked by the compiler.

    • / routes/index.tsx
    • /todos routes/todos.tsx
    • /blog/:slug routes/blog/[slug].tsx
  • Zero config, all escape hatches

    Sensible defaults for TypeScript, CSS, images and env vars. A config file when you need one - and only the line you change.

  • Hot reload you do not notice

    Save a file and the change is on screen before you look up - state kept.

    38 ms

  • Runs where you deploy

    One build, many targets: Bun, Node, Deno, Cloudflare Workers or a folder of static files.

    All adapters

// try it

Read the code, then run it.

Three files make an app. The terminal is real - type into it.

import { server } from 'weft';
import { db } from '../server/db';
import Counter from '../islands/Counter';
export const load = server(() => db.posts.latest(5));
export default function Home({ data }) {
  return (
    <main>
      {data.map((p) => <a href={`/blog/${p.slug}`}>{p.title}</a>)}
      <Counter start={3} />
    </main>
  );
}

Keys: ↑ history, Tab completes, Ctrl L clears.

// benchmarks

Fast where your users feel it.

The same blog app, built three ways. Lower is better, except where it says otherwise.

JavaScript sentper page view, KB compressed
weft 4.2
14
weft 3
41
a typical SPA
126
Cold startedge function, first request, ms
weft 4.2
9
weft 3
23
a typical SSR server
61
Throughputrequests a second, higher is better
weft 4.2
52,400
weft 3
38,900
a typical SSR server
11,700

weft-bench 2.3 · Apple M3 Pro, 64 connections, 30 s per run, median of five · the harness and the raw runs are in the repository.

// in production

What teams deleted.

  • We deleted our whole API package - 4,000 lines of handlers and types that only existed to keep two codebases in sync.
    Priya RamanStaff engineer, Tidewater
  • Our landing page went from 180 KB of JavaScript to 11. Same design, same team, one afternoon.
    Jonas WeberFrontend lead, Kestrel Bank
  • The error messages tell you which file to open and which line to change. I read them instead of searching.
    Ana FerreiraIndie developer, Lisbon
// deploy

One build, wherever you run.

An adapter is one line in your package.json. Switch it and build again.

Bun default

Server

One binary with your app inside - weft build --compile.

Node

Server

Node 20 and later, as a plain HTTP handler or behind your own server.

Deno

Server

With permissions written for you: net, read and env, nothing else.

Cloudflare Workers edge

Edge

Each route a function, the islands on the CDN.

Static

Files

Prerenders every route it can and tells you which ones it could not.

Docker

Container

A 38 MB image from a Dockerfile weft writes - read it before you use it.

// changelog

Four releases, nothing broke.

A minor release every quarter; an upgrade is one command and has needed no codemod since 4.0.

  1. 4.3 Partial prerendering

    A route's static shell comes from the CDN; its islands are filled in at the edge.

  2. 4.2 Islands that stream

    • feature Islands wake in the order their data arrives - the page never waits for the slowest query.
    • feature Typed form actions: a form's fields are checked against the server function it posts to.
    • speed The dev server starts 40 % faster; the module graph is cached between runs.
    • fix Source maps point at the line you wrote, not at the split.
  3. 4.1 Routes you can type

    Links are checked by the compiler: a renamed file fails the build, not your users.

  4. 4.0 One thread

    server() functions live in the file that calls them; the API layer is gone.

Pick up the thread.

One command makes a project. The tutorial takes twenty minutes and ends with an app on the internet.

bun create weft@latest

Start a project

Pick a template; we write the command. Leave your email for the tutorial.

Template
Package manager
Your command bun create weft@latest hello --template app

The tutorial is on its way

Run this in a terminal while it arrives:

Imprint

Who runs this site

Privacy

What we keep, and why