trails is not Ruby in disguise. It is TypeScript from the first line, built on the tools JavaScript developers already use, and it runs wherever JavaScript runs.
~/code
Node
Bun
Cloudflare Workers
AWS Lambda
React Native
Electron
Your browser
No Ruby at run time.
No Ruby interpreter, no transpiler, no VM. Nothing in trails runs, parses or evaluates Ruby.
Each Rails framework is ported by hand to TypeScript, method by method, so a Rails developer recognizes every name. What runs is ordinary JavaScript. Templates (.tse, TypeScript Embedded) compile ahead of time to TypeScript functions, so nothing evaluates generated code at run time. The ruby-compat package, a library of Ruby semantics Rails depends on (dup, fetch, mixins), is TypeScript through and through.
01
Typed from end to end.
Types come straight from your database, through your app, and out into OpenAPI. bin/trails build reads db/schema.ts, the schema dumped from your real database, so every model attribute has its column’s type with nothing to declare by hand. Views are type-checked, so a template that passes the wrong locals to a partial fails the build, not the request. The OpenAPI document is built from what each action passes to render, so your frontend, in whatever framework you choose, works from the database’s real types. It’s all compiled quickly by the TypeScript 7 native compiler.
02
async/await and ESM.
Queries, validations, saves, jobs and mail delivery return real promises that you await. No fibers, no hidden blocking. Every package is an ES module. trails’ own lint gates fail the build on any promise that nothing awaits or handles, so a rejection never disappears.
03
Temporal for dates and times.
Active Support’s time zones, durations and date math are built on Temporal: Instant, PlainDate, ZonedDateTime. Temporal was chosen for precision. JavaScript’s Date stops at milliseconds, but database timestamps carry microseconds and Ruby’s Time keeps nanoseconds. Temporal keeps every digit, so a timestamp isn’t truncated on its way through your app. Where a runtime doesn’t ship Temporal yet, trails loads the official polyfill.
04
WebSockets on Node’s event loop.
Rails’ Action Cable runs its own selector thread (nio4r) to watch sockets. Node already has an event loop, so trails drops the selector and lets Node say when a socket is readable. Frames are parsed by the npm websocket-driver, the JavaScript sibling of the gem Rails uses, and the official @rails/actioncable client connects unchanged.
Modern frontend. Your framework.
One language, backend and frontend: models, controllers and views are TypeScript, and your UI can be too.
Vite serves your assets.
trails ports vite_ruby and vite_rails, so trails new gives you a Vite dev server with hot reloading and a production manifest. The app generator also accepts bun, webpack, esbuild or rollup.
Bring your own frontend.
Use React, Ember.js, Svelte or Vue through Vite, or skip the single-page app and update pages over the wire with Turbo and Stimulus, using Hotwire’s official npm packages.
pnpm and bun.
A new app is a pnpm project, and trails installs just as easily with bun. Move an app to bun and the generators follow: the install tasks see bun.lockb and use bun.
One SQLite. Every runtime.
trails’ sqlite3 package ports the Ruby gem’s API once and runs it on six engines. Your models don’t change. One line of config does.
config/database.ts
const db = {
adapter: "sqlite3",
database: "db/app.sqlite3",
};
export default { development: db, test: db, production: db };
app/models/post.ts · unchanged
class Post extends Base {
declare title: string;
declare published: boolean;
static {
Post.validates("title", { presence: true });
}
}
await Post.createBang({ title: "Hello" });
Node, synchronous and fast. On Bun, the same adapter picks bun:sqlite for you.
A few features depend on what the engine exposes. Interrupting a running query needs libsql or expo-sqlite, and user-defined SQL functions need better-sqlite3 or node:sqlite. Elsewhere those calls raise NotImplementedError. PostgreSQL and MySQL/MariaDB are supported too.
Deploy wherever.
Each card links to a working example app in the repository.
The OpenAPI generator reads your routes and your controllers’ TypeScript types and writes an OpenAPI document to tmp/openapi.json, with no annotations to maintain. In development, /trails/info/api renders it. Run it with --check in CI to fail the build when the API changed and the document wasn’t regenerated.
See it run.
The playground boots a full trails app, models to views, in this browser tab.