create-native-rust
v0.2.0
Published
Scaffold a napi-rs crate ready to import from Vite SSR server code with vite-plugin-native-rust.
Maintainers
Readme
create-native-rust
Scaffold a napi-rs crate that's ready to import directly from
your Vite SSR server code with
vite-plugin-native-rust.
Experimental — 0.1. See the plugin repo for the supported matrix.
Usage
npm create native-rust native
# or with an explicit binary name
npm create native-rust native -- --name nativeThis generates, in ./native/:
Cargo.toml— acdylibcrate with napi v3 + napi-derive v3 and anlto+striprelease profile.build.rs—napi_build::setup().src/lib.rs— a syncaddand an asyncsumTosample export, both doc-commented so the generated types carry the docs into your editor.package.json— carries thenapi.binaryNamethat napi v3 requires..gitignore— ignorestarget/and*.node.Cargo.lock— generated at scaffold time viacargo generate-lockfile(when cargo is on your PATH; skipped with a printed note otherwise). Commit it: the lockfile is part of the plugin's compile-cache key, so a crate born without one changes key after its first compile and costs cold multi-step builds (e.g. Nuxt's Vite + Nitro pipelines) an extra identical ~30s compile.
After scaffolding, the CLI prints the exact vite.config, tsconfig, and import wiring to finish hooking the crate into your app — the same steps as the plugin quickstart.
Options
| Flag | Description |
| --- | --- |
| --name <binaryName> | Crate/binary name. Defaults to a sanitized form of <dir>. |
| -h, --help | Show help. |
The CLI refuses to overwrite a non-empty directory and validates that the name
is a usable crate/npm identifier (lowercase, starts with a letter, -/_
separators).
License
MIT
