@orion-js/native. Orionjs 5.0
turns the model around: a Rust binary (orionrs) can be the host process of your app.
The Rust host owns the public HTTP port, the background job scheduler, and the Pulse event
consumers. Routes, jobs, and echoes declared in Rust run in Rust; everything else goes to your
Orionjs app, which keeps running in Bun or Node behind a private unix socket. Moving a controller
to Rust is a local change—declare it in Rust, and the JS worker stops receiving it.
The Rust host is opt-in. Without it, a v5 app runs the same way as v4. All @orion-js/* npm
packages and orionrs* crates are aligned at 5.0.0.
Why the host has to be Rust
When Node or Bun is the host, every HTTP request, job claim, and Pulse event passes through the JavaScript event loop first. Calling native code helps for CPU-bound functions, but the event loop remains the ceiling for everything that enters the process. With Rust in front (built ontokio, tower, and axum), migrated controllers never touch Node.
On examples/backend-base, measured with ab (keep-alive, 50 connections):
The Rust number is probably limited by
ab itself. Proxying a route that still lives in Node costs
about 12%, which is what you pay until you move it.
Migrate whole flows, one controller at a time
Rust does not call into your JS services. Instead, you migrate complete flows—a route, the job it schedules, the event that job publishes—one controller at a time. Everything not yet declared in Rust falls back to the Orionjs worker over a private unix socket (ORION_HOST=rust,
ORION_HOST_SOCKET, and a per-process ORION_HOST_TOKEN):
- HTTP routes: Rust routes are plain
axumhandlers.Error::user,Error::validation,Error::auth, and internal errors (?) return the same JSON payloads and SHA-1 hashes as@orion-js/http, andJwt<Claims>verifiesAuthorization: Bearertokens usingjwt_secretfrom your env file. Unmatched paths—and unmatched HTTP methods on a path partially moved to Rust—are proxied to Node. - Jobs: With
.jobs(...),orionrs-jobsruns the claim loop, adaptive index hint probe, and partition reconciler against the same@orion-js/dogscollections. Jobs defined in Rust run in Rust; jobs defined only in JS are claimed by the host and dispatched to Node throughjobs.executeandjobs.filter, keeping JS options likeonError,onStale,getNextRun,executionGuard,canTakeJobs, andgetJobsFilter.startWorkers()in your app stays unchanged—under the host it registers jobs instead of polling. If a job is defined in both, Rust wins. - Echoes: With
.echoes(...)and.pulse(...),orionrs-echoesconsumes events withorionrs-pulse(a Rust port of@orion-js/pulse) and handlesPOST /echoes-services. Rust echoes run in Rust; JS event echoes are delivered to Node viaechoes.deliverwith the same retries and dead letters, and JS request echoes are forwarded to the app. If you omit.pulse(...), the host handles Rust request echoes while the app keeps consuming its own Pulse events. - Env and MongoDB:
orionrs-envreads the same encryptedorion-envYAML file (both post-quantumpq1:and legacy formats), andorionrs-mongoconnects with the official MongoDB driver using Orionjstyped_id,random_id, and BSON/ISO date helpers.
ORION_NODE_COMMAND="bunx orion dev" so orion dev restarts
Node on file changes while the host keeps the port open and holds incoming requests until Node is
back. On SIGTERM, the host drains active requests, jobs, and events across both runtimes before
stopping Node’s process group. If Node exits on its own, the host exits with an error so your
orchestrator restarts both.
Compatible with v4 during rolling deploys
Other than the Kafka removal below, v5 keeps the same storage schemas and wire formats as v4:- Jobs use
orionjs.jobs_dogs_recordsandorionjs.jobs_dogs_historywith the same claim and lock protocol. - Pulse uses the same collections, leases, and delivery states.
- Echoes requests (
/echoes-services) use the same signature and serialization format.
Breaking change: Kafka is removed from Echoes
@orion-js/echoes now uses Pulse as its only event
transport, which requires nothing beyond MongoDB. Top-level client, producer, and consumer,
events.kafka, events.consumeFrom, events.publishTo, onMessage, and publish()’s acks /
timeout options have been removed. events.pulse is unchanged.
If you still consume or publish through Kafka, switch to Pulse on Orionjs v4 first—v4 can consume
from both Kafka and Pulse during the transition—using the
v4 incremental Kafka-to-Pulse guide,
then follow Upgrading to v5. The full v4 documentation stays available
under the v4 option in the version switcher.
Try it
A minimal host sits in aserver/ crate next to your Orionjs app:
ORION_ENV_FILE_PATH and ORION_ENV_SECRET_KEY:
examples/backend-base
to see a flow that crosses Rust and JavaScript four times (POST /examples in Rust →
example.created in JS → processExample job in JS → example.processed in Rust) along with
end-to-end tests (bun run e2e) that boot the real host binary.