Getting started
To start with LongHorn, run npm create longhorn@latest to generate a project. The new project has its own copy of the framework, plus tests and guides.
LongHorn is an early alpha. It has not been deployed to production, and its APIs can still change.
What you need
- Node 20.19 or newer
- pnpm 12.6
Create a project
npm create longhorn@latest my-api -- --runtime node
cd my-api
pnpm install
pnpm devcurl http://127.0.0.1:3000/health
# {"status":"ok","runtime":"node","ready":true}The smallest app
app.http is a real Hono app, so Hono routers and middleware work directly.
import { Longhorn } from '@longhornjs/core'
import { nodeRuntime } from '@longhornjs/node'
const app = new Longhorn()
app.http.get('/hello/:name', (c) =>
c.json({ message: `Hello, ${c.req.param('name')}` }))
const server = await app.listen(nodeRuntime, { port: 3000 })
console.log(server.url)Choose a starting template
| You are building | Create it with |
|---|---|
| An HTTP API | npm create longhorn@latest my-api -- --runtime node, or bun, deno, workers |
| An app with a database | pnpm create:app ../my-app --runtime node --template sqlite-tasks, or bun, deno |
| An app with accounts | pnpm create:app ../my-app --runtime node --template sqlite-auth, or bun, deno |
| A Worker with storage | pnpm create:app ../my-app --runtime workers --template d1-tasks |
| The complete console | pnpm create:app ../my-app --runtime node --template command-app, which needs PostgreSQL |
Templates don't work from the npm 0.1.0 packages yet, so pnpm create:app runs from a clone of the repository, after pnpm install.
Next: run it on another host, or read the starter guide.