Repository navigation
Examples
Edgar Cano edited this page Oct 12, 2026
·
4 revisions
The examples/ directory of the 3va repository holds 13 small projects. Each one shows a different facet of the runtime: what it does, how to run it, what you should see, and what to watch out for.
Everything here was run against 3va 2.9.0 on Linux, non-interactively (no TTY). See the docs site Examples section for the full walkthrough of each project with real output.
git clone https://github.com/OdinoCano/3va
cd 3va/examples/01-hello-world
3va run app.js| # | Example | What it shows | Command |
|---|---|---|---|
| 01 | Hello World | The simplest script, zero permissions | 3va run app.js |
| 02 | HTTP Server | Node http + --allow-net
|
3va run server.js --allow-net=localhost |
| 03 | File Operations | Scoped --allow-read / --allow-write
|
3va run app.js --allow-read=./data.json --allow-write=./data.json |
| 04 | TypeScript | Running .ts with no build step |
3va run math.ts |
| 05 | npm Packages |
3va install + package.json grants |
3va install --allow-net=registry.npmjs.org |
| 06 | Dev Server | On-demand ESM serving + full-page HMR | 3va dev --port 3000 |
| 07 | Test Runner | Jest-compatible tests and snapshots | 3va test |
| 08 | Bundler | Multi-file → one self-contained file | 3va bundle src/index.js -o dist/bundle.js --minify |
| 09 | Process Manager | Background daemon + auto-restart | 3va start server.js --name demo-api |
| 10 | Permissions | Deny-by-default, grant by grant | 3va run demo.js |
| 11 | React Native | Run and test the shared TS logic of an RN app | 3va test |
| 12 | Expo | Expo helpers and tooling scripts | 3va run src/index.ts --allow-read=./src |
| 13 | Tauri | 3va as the frontend toolchain of a Tauri app |
3va dev / 3va bundle / 3va test
|
| 14 † | Native addon | A real .node addon (bcrypt) through Node-API and --allow-ffi
|
3va run app.js --allow-ffi ... |
† Example 14 needs 2.12.1 or newer: on 2.12.0 the asynchronous call never prints its result and addons that define classes can crash on load.
- 01 hello world → 03 files → 02 HTTP server (the two most common capabilities)
- 04 if you write TypeScript
- 07 tests, 05 dependencies
- 06 develop with HMR, 08 ship a bundle, 09 run it as a daemon
- 10 to understand why everything above needs the flags it needs
- 11 · 12 · 13 if you work with a native app framework
These came up again and again while running the examples, so they are collected here once:
-
Importing your own files needs
--allow-read. The entry file is always readable, but every module it imports is a file read. A single-file script (01, 04) needs no flags; a script that imports./todos.tsfails withPermission denied: --allow-read=…/src/todos.ts is requireduntil you pass--allow-read=./src. The same goes forrequire()of packages innode_modules(05). -
Denials look different depending on the API. A synchronous
fscall throws (EACCES, or an uncaughtPermission denied: --allow-… is requiredthat exits with code 1).process.envquietly looks empty. An async network call reports anEACCESerrorevent, and if nothing listens for it, the script exits with code 0 (02). 3va lists every refusal when the run ends (env vars included, when read by name), with the flag to add, and--trace-denialsshows each one as it happens. -
No TTY, no prompt. In a terminal, 3va asks before granting a missing capability. In CI, pipes, or redirected output it denies silently.
"no-prompt": trueinpackage.jsonmakes that behavior explicit. -
3va permissions learn <script>runs the script with everything allowed and prints the exact flags it used. Add--writeto merge them intopackage.json. It is the quickest way to find the minimum set.3va permissions suggestonly reads the source and produces broad"."scopes. -
⚠ Dependencies may be out of dateis printed whenever a folder has apackage.jsonbut no installednode_modules(examples 09 and 13). It is harmless for these examples, which have no dependencies.
See Permissions for the full model and CLI Reference for every command used above.