npm.io
0.2.2 • Published 1 week ago

@swift-rust/video

Licence
MIT
Version
0.2.2
Deps
0
Size
53 kB
Vulns
0
Weekly
0
Stars
3

Swift Rust

The full-stack React framework powered with Rust + Bun. Inspired by Next.js. 10x faster than Next.js. Write your UI in TSX, render on the server with Rust, and ship a single binary.

Features

  • TSX-first — Author components in TypeScript with first-class TSX syntax, just like TanStack Start. A custom SWC plugin transforms TSX into optimized Rust view templates.
  • Multi-target rendering — Choose per project: full SSR, SSR + WASM hydration, server-rendered HTML with HTMX islands, or a fully client-rendered WASM SPA.
  • Built-in components — Image, Font, and Pdf components handle optimization, loading, and document generation out of the box.
  • Zero-config dev server — swift-rust dev starts a hot-reloading dev server with sensible defaults.
  • Single binary deployment — Compile your entire app to one Rust binary. No Node.js required in production.
  • File-based routing — Like Next.js: files in app/ become routes automatically.

Repository layout

swift-rust/
├── crates/        Rust workspace (framework core, compiler, server, bundler, runtime)
├── packages/      JS/TS packages (swift-rust, create-swift-rust, font, bundle-analyzer, eslint-*, env)
├── docs/          Documentation site
├── errors/        Error code reference and schemas
├── scripts/       Build, release, and CI scripts
├── test/          Integration and end-to-end tests
└── examples/      Example applications

Quick start

# Scaffold a new project
bun create swift-rust@latest my-app
# or
bunx create-swift-rust@latest my-app

# Enter and start dev server
cd my-app
bun install
bun swift-rust dev

Open http://localhost:3000.

Rendering modes

Swift Rust supports four rendering strategies. Pick the one that fits your project:

Mode Use case
ssr Server-renders full HTML. Lightest. No client JS.
ssr-wasm SSR first paint + WASM hydration for interactivity.
ssr-htmx SSR with HTMX islands for progressive enhancement.
wasm Full WASM SPA with optional SSR shell.

Set the mode in swift-rust.config.ts:

import { defineConfig } from "swift-rust";

export default defineConfig({
  rendering: "ssr-wasm",
  components: {
    image: { domains: ["cdn.example.com"] },
    font: { subsets: ["latin"] },
  },
});

Built-in components

<Image>
import { Image } from "swift-rust/image";

export default function Hero() {
  return <Image src="/hero.jpg" width={1200} height={600} priority alt="Hero" />;
}
<Font>
import { Inter } from "swift-rust/font/google";

const inter = Inter({ subsets: ["latin"], display: "swap" });

export default function RootLayout({ children }) {
  return (
    <html lang="en" className={inter.className}>
      <body>{children}</body>
    </html>
  );
}
<Pdf>
import { Document, Page, Text, View } from "swift-rust/pdf";

export default function Invoice({ items }) {
  return (
    <Document>
      <Page size="A4">
        <View>
          <Text>Invoice</Text>
          {items.map((it) => (
            <Text key={it.id}>{it.name}: ${it.price}</Text>
          ))}
        </View>
      </Page>
    </Document>
  );
}

Running the examples

cargo build --release -p swift-rust
export PATH="$PWD/target/release:$PATH"
cd examples/hello-world && bun install && swift-rust dev

See PUBLISHING.md for the full release flow.

Project status

This is pre-alpha. The scaffold is in place; the framework core is under active development.

Contributing

See CONTRIBUTING.md and AGENTS.md.

License

MIT