npm.io
1.10.11 • Published 2 months agoCLI

swift-rust

Licence
MIT
Version
1.10.11
Deps
8
Size
278 kB
Vulns
0
Weekly
0
Stars
3
Install scriptsThis package runs scripts during installation (preinstall/install/postinstall)

swift-rust

The main swift-rust npm package. Installing it in a project gives you:

  • A swift-rust bin on PATH (or via npx swift-rust).
  • Imports for <Image>, <Font>, <Document>, <Head>, <Link>, etc.
  • A defineConfig helper for swift-rust.config.json.

The framework binary is downloaded at install time from GitHub Releases. If no prebuilt binary is available for the user's platform, cargo build is run as a fallback.

Install

npm install swift-rust
# or
bun add swift-rust
# or
yarn add swift-rust

Usage

CLI
npx swift-rust dev      # start dev server
npx swift-rust build    # production build
npx swift-rust start    # start production server
npx swift-rust info     # print environment
In code
import { Image, Inter, Document, Page, Text, View } from "swift-rust";

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

export default function Home() {
  return (
    <html lang="en" className={inter.className}>
      <body>
        <Image src="/hero.jpg" width={1200} height={600} alt="Hero" priority />
      </body>
    </html>
  );
}

Subpath exports

Path What it exposes
swift-rust Everything (config, components, types).
swift-rust/image <Image> component + types.
swift-rust/font Font helpers + types.
swift-rust/font/google Google Fonts families.
swift-rust/font/local localFont for self-hosted fonts.
swift-rust/pdf <Document>, <Page>, <Text>, <View>.
swift-rust/env Env loading + SWIFT_RUST_PUBLIC_* helpers.
swift-rust/router Route handler types.
swift-rust/head <Head> metadata.
swift-rust/link <Link> client navigation.

Publishing

This package is built from packages/swift-rust/ in the monorepo.

# 1. Build native binaries for all platforms
SWIFT_RUST_VERSION=0.1.0 bun run scripts/package-native.ts

# 2. Publish to npm
cd packages/swift-rust
bun publish

The prepublishOnly script runs both steps automatically.

Keywords