@acryldev/blends
v1.7.43
Published
The Acryl web framework (import { Acryl } from "acrylblends") and the acrylblends command that scaffolds Cordis apps.
Readme
Get started
Install ACRYL Control Center in one line. No Node and no admin for the app itself (if git or a desktop library is missing, Linux asks for sudo once), the download is checked against GitHub's sha256, and Windows and macOS open it without warnings because it is not browser-downloaded.
macOS and Linux
curl -fsSL https://acryl.dev/install.sh | bashWindows (PowerShell)
irm https://acryl.dev/install.ps1 | iexDevelopers: npx acryl@latest
import { Acryl } from 'acrylblends'
const app = new Acryl()
app.get('/', (c) => c.text('Acryl!'))
export default appContents
- Requirements
- Start an app in five minutes
- Run it in a browser or in a desktop window
- Start from the registry
- Publish your app, or your own starter
- Keep the framework current
- Use it as a library
- A first API
- Middleware
- Validation
- Typed client
- Testing
- Serving on Node.js
- What is in the package
- Upgrading from an older version
- The acrylblends command
- Links
- License
Requirements
- Node.js 22.19 or newer. Node.js is the verified runtime, and it runs
.tsfiles directly, so there is no build step. - Bun runs the same app (
export default app) and is experimental. acrylblendshas no dependencies. Its types need only Node's types (@types/node), not the DOM library.
Start an app in five minutes
npm create @acryldev/blends@latest my-app
cd my-app
npm install
npm run devThe starter asks which template you want; naming one skips the question (npm create @acryldev/blends@latest my-app notes).
| Template | What you get |
| --- | --- |
| blank | the router, the Node server and one route: the smallest app |
| nodejs | a page rendered with JSX and a client component, without a bundler |
| notes | a multi-user notes app on the db port: sign-up, sessions, migrations, search, a typed client |
| chat | an answer streamed over server-sent events from an OpenAI-compatible API, history in SQLite |
| todo | a to-do list on the router and live state |
| agent | the blank app with an agent that writes and installs plugins into the running app |
Every template is a Cordis app: blend.yaml lists its plugins, plugins/ holds them as code you own, and the starter also writes
docs/framework (the pages this README links to), AGENTS.md, CLAUDE.md, one skill for a coding agent, and its own tests. npm run dev
serves it and prints the URL, npm test runs the tests, npm run check type-checks.
Adding a capability is one command: npx @acryldev/blends add <plugin> copies a library plugin and what it needs into plugins/, prints the row to
add to blend.yaml, and records what it copied so acrylblends upgrade can move it forward later. npx @acryldev/blends plugins lists the library.
Run it in a browser or in a desktop window
The same app runs both ways; the routes, the plugins and the data are the ones you already wrote.
- Browser: what you get.
npm run dev(ornpm start) serves it on a loopback port and prints the URL. - Desktop: add the shell and run it as a window on the app's own server.
npx @acryldev/blends init my-app --desktop # create an app with the shell (--template picks the template)
# or, in an app you already have:
npx @acryldev/blends add desktop
npm install # the shell needs electron
npm run desktop # an Electron window on the app's own serverEvery Electron call lives in plugins/desktop-shell, so the app's own code never imports it. See
Desktop.
Start from the registry
The registry is a set of starting points people published, browsable at acrylblends.github.io/blends
and readable by any tool as plain JSON at https://acrylblends.github.io/registry/index.json. Each entry says which runtime it is for. An
acrylblends starter is a whole app, and one command makes it from npm alone:
npm create @acryldev/blends@latest my-notes -- --from acrylblends.notes-desktop # npm needs the -- before the options
cd my-notes
npm install
npm run devThe other starters in the registry (acryl.gtd, acryl.blank, ...) are for the ACRYL app: @acryldev/create-blends refuses them with a line that
says so. A repository with an acryl.template.json works the same way (-- --from github:you/starter), and a team's own registry is the same
layout in its own repository (-- --from you.thing --registry github:you/registry).
Publish your app, or your own starter
Your app belongs to you and lives in your repository: npm run save commits it and pushes to its remote. It refuses a file that looks like
a secret, and refuses to push a private app to a public remote.
Before an app goes on a server: with NODE_ENV=production the door, the agent panel and the PTY driver start nothing, the agent template leaves its agent, builder and extensions rows out
(ACRYL_PRODUCTION_KEEP names the ones to keep, with a warning), and the chat template is closed until it has a CHAT_ACCESS_TOKEN
A starter other people can pull is a pull request to the registry repository: add registry/blends/<id>/ with your app as it stands (without node_modules/
and dist/), its blend.yaml made public (id, a licence, a category and a one-line description) and an acryl.template.json, which is what marks it as an
app for acrylblends. CI validates every entry, makes the app with @acryldev/create-blends, and fails when index.json is stale, so what the site lists is what
passed. The layout, and how to keep a starter private without a registry at all, is in
the registry README.
Keep the framework current
An app carries its framework plugins as source, so a new release moves them in place and leaves your own code alone:
npx @acryldev/blends@latest upgrade --dry-run # the plan: what would be replaced
npx @acryldev/blends@latest upgrade # an edited file stops it with the diff, unless --forceWrite @latest: a bare npx @acryldev/blends upgrade runs the copy the app has installed, and an app made before 1.0 has an old one with no upgrade verb (it prints its help and exits 0, so it looks as if it worked, or answers "unknown command" and exits 2).
Use it as a library
An Acryl app is also a plain function from Request to Response, which needs no scaffold. Create a folder and install the package:
mkdir my-app && cd my-app
npm init -y
npm pkg set type=module
npm install @acryldev/blendsWrite the app in index.ts:
import { Acryl } from 'acrylblends'
const app = new Acryl()
app.get('/', (c) => c.text('Acryl!'))
export default appServe it on Node.js with the adapter in server.ts:
import { serve } from '@acryldev/blends/node-server'
import app from './index.ts'
serve({ fetch: app.fetch, port: 3000 }, (info) => {
console.log(`Listening on http://localhost:${info.port}`)
})Run it and open http://localhost:3000:
node server.tsFor Bun, bun run index.ts serves the same export default app. The same app mounts inside a Cordis plugin with
ctx.router.route(prefix, app), which is how a generated app is put together: see
Acryl in a Cordis app.
A first API
import { Acryl } from 'acrylblends'
import { HTTPException } from '@acryldev/blends/http-exception'
type Book = { id: string, title: string }
const books = new Map<string, Book>()
const app = new Acryl()
app.get('/api/books', (c) => c.json([...books.values()]))
app.get('/api/books/:id', (c) => {
const book = books.get(c.req.param('id'))
if (book === undefined) throw new HTTPException(404, { message: 'no such book' })
return c.json(book)
})
app.post('/api/books', async (c) => {
const { title } = await c.req.json<{ title: string }>()
const book = { id: crypto.randomUUID(), title }
books.set(book.id, book)
return c.json(book, 201)
})
app.notFound((c) => c.json({ error: 'not found' }, 404))
app.onError((error, c) => error instanceof HTTPException ? error.getResponse() : c.json({ error: 'internal error' }, 500))
export default appRead more: Routing, Context, Request, Exceptions.
Middleware
Each built-in middleware has its own subpath:
import { Acryl } from 'acrylblends'
import { cors } from '@acryldev/blends/cors'
import { logger } from '@acryldev/blends/logger'
import { secureHeaders } from '@acryldev/blends/secure-headers'
import { bearerAuth } from '@acryldev/blends/bearer-auth'
const app = new Acryl()
app.use(logger())
app.use(secureHeaders())
app.use('/api/*', cors())
app.use('/admin/*', bearerAuth({ token: process.env.ADMIN_TOKEN ?? '' }))Built in: basic-auth, bearer-auth, body-limit, combine, compress, context-storage, cors, csrf, etag, ip-restriction,
jwk, jwt, language, logger, method-not-allowed, method-override, powered-by, pretty-json, request-id, secure-headers,
serve-static, timeout, timing, trailing-slash, plus ACRYL's loopback-only. Each one is documented under
Middleware. To write your own, see the
middleware guide.
Validation
acrylblends/validator validates any part of a request: json, form, query, param, header, cookie. The validated value is typed
in the handler:
import { Acryl } from 'acrylblends'
import { validator } from '@acryldev/blends/validator'
const app = new Acryl()
app.post(
'/api/books',
validator('json', (value, c) => {
const title = (value as { title?: unknown }).title
if (typeof title !== 'string' || title === '') return c.json({ error: 'title is required' }, 400)
return { title }
}),
(c) => c.json({ title: c.req.valid('json').title }, 201),
)acrylblends/schema-validator drives the same validator with any Standard Schema library (Zod, Valibot,
ArkType and others). See the validation guide.
Typed client
Export the app's type, and acrylblends/client calls its routes with typed paths, inputs and answers:
// api.ts
import { Acryl } from 'acrylblends'
const app = new Acryl().get('/api/hello', (c) => c.json({ message: 'Acryl!' }))
export type AppType = typeof app
export default app// client.ts
import { hc } from '@acryldev/blends/client'
import type { AppType } from './api.ts'
const client = hc<AppType>('http://localhost:3000')
const answer = await client.api.hello.$get()
console.log((await answer.json()).message)See RPC.
Testing
app.request() answers a request in process, with no server and no port, so tests need nothing else running:
import assert from 'node:assert/strict'
import { test } from 'node:test'
import app from './index.ts'
test('GET / says hello', async () => {
const response = await app.request('/')
assert.equal(response.status, 200)
assert.equal(await response.text(), 'Acryl!')
})Run it with node --test. acrylblends/testing adds testClient, the typed client over app.request(). See the
testing guide.
Serving on Node.js
acrylblends/node-server serves any Acryl app on Node's http module (or http2 and https with createServer), streams bodies, aborts
c.req.raw.signal when the client goes away, and serves files:
import { Acryl } from 'acrylblends'
import { serve } from '@acryldev/blends/node-server'
import { serveStatic } from '@acryldev/blends/node-server/serve-static'
import { getConnInfo } from '@acryldev/blends/node-server/conninfo'
const app = new Acryl()
app.use('/static/*', serveStatic({ root: './' }))
app.get('/ip', (c) => c.text(getConnInfo(c).remote.address ?? 'unknown'))
const server = serve({ fetch: app.fetch, port: 3000, hostname: '127.0.0.1' })
process.on('SIGTERM', () => { server.close() })See Node.js.
What is in the package
| Import | What |
| --- | --- |
| acrylblends | Acryl, Context, AcrylRequest, and the types |
| acrylblends/<middleware> | each built-in middleware, for example acrylblends/cors |
| acrylblends/validator, acrylblends/schema-validator | request validation |
| acrylblends/client, acrylblends/testing | the typed client and its in-process test version |
| acrylblends/accepts, adapter, cookie, factory, html, route, streaming, ws, conninfo | helpers (helpers docs) |
| acrylblends/http-exception | HTTPException |
| acrylblends/router/* | the routers: reg-exp-router, smart-router, trie-router, pattern-router, linear-router (routers) |
| acrylblends/tiny, acrylblends/quick | the presets: Acryl with another router (PatternRouter; LinearRouter and TrieRouter) (presets) |
| acrylblends/cache, acrylblends/mount | the cache middleware and mounting another framework's fetch handler |
| acrylblends/ssg | static site generation: toSSG writes every route as a file (SSG helper) |
| acrylblends/proxy, acrylblends/dev | the proxy helper and the dev helpers (showRoutes, inspectRoutes, getRouterName) |
| acrylblends/jsx | JSX on the server: jsxImportSource: '@acryldev/blends/jsx', .tsx files run on Node with node --import acrylblends/node-server/register, with jsx/streaming, and acrylblends/jsx-renderer for a layout behind c.render (JSX guide) |
| acrylblends/jsx/dom | JSX in the browser: hooks and render (needs the DOM library) (client components); on Node, clientModules serves them to the browser without a bundler (guide) |
| acrylblends/drivers | the driver contract of the agent panel (ChatDriver, TerminalDriver, Drivers), for plugins that add an agent to the panel |
| acrylblends/css | CSS in JSX: css, cx, keyframes, Style (CSS helper) |
| acrylblends/node-server | serve, createAdaptorServer, getRequestListener; with node-server/serve-static, node-server/conninfo, and node-server/register (compiles .tsx with the app's typescript); clientModules and buildClientModules (client components without a bundler) |
Every subpath in the table is listed in the package's exports and is covered by semver from 1.0, except the ones marked experimental: acrylblends/bun and the door (door/*, cordis/door), which are development tools. The ported core's utilities (utils/*) and the base-class chunk are internal and not exported. Node.js is the runtime the package is verified on; the upstream's adapters for AWS Lambda, Lambda@Edge, Cloudflare, Vercel, Netlify and Service Workers are not part of the package (Other runtimes).
To extend the context's typed variables, augment the root module:
declare module 'acrylblends' {
interface ContextVariableMap {
user: string
}
}Upgrading from an older version
An app made with any 0.9.1 or later release moves with acrylblends upgrade (above); its edited files are never replaced silently.
An app made by a published release from 0.7.8 on that still runs on the standalone layout also moves onto the ACRYL frame: acrylblends upgrade writes
scripts/ide-host.mjs, the generated overlay (cordis.patch.yml with the app's own rows and the frame rows), cordis.yml, app/runtime.mjs and
frame/app-plugins.mjs (with the entry isolate the app's services need), brings src/app.ts, src/routes.ts (or the template's route module) and
src/frame.ts up to date when they are still the released template's, copies the two host plugins (@acryldev/web-server, @acryldev/page), and points
npm run dev at the frame; npm start keeps the app's own server and URLs. A file you edited stops the upgrade (nothing is written) unless --force
backs it up first, and blend.yaml is never touched. The frame packages' specs come from ACRYLBLENDS_FRAME_PACKAGES while they are unpublished.
An app made before 0.7.8 cannot be carried forward: those releases wrote src/main.ts importing ./plugins/... where the plugins are one folder up, so the
app could not start as scaffolded; the upgrade says so and asks for the ../plugins/... paths (0.7.8 fixed them) before it writes the frame.
Code that imports the old names moves by hand: App and AppRequest, the 0.4 aliases of Acryl and AcrylRequest, are removed in 1.0, and
the scaffolding API that was the package root in 0.4 is now acrylblends/cli. See
Migration to 1.0 and
Migration from 0.4.
The acrylblends command
The package also carries the acrylblends command. It scaffolds Cordis apps with ACRYL's plugins as code you own (instance, settings,
plugins installed while the app runs, an agent that builds plugins, durable tasks, the app as data in blend.yaml, a save that refuses
secrets):
npx @acryldev/blends@latest init my-app -y
cd my-app && npm install && npm run dev # the app in the ACRYL frame: chat, agents, branches, versions, Settings
npm run desktop # the same in its own window--bare makes the plain app without the frame.
See the ACRYLBLENDS documentation and Acryl in a Cordis app.
Links
| | |
| --- | --- |
| Framework documentation | https://github.com/acrylblends/acrylblends/blob/main/docs/framework/README.md |
| ACRYLBLENDS website | https://acrylblends.github.io |
| ACRYL website | https://acryl.dev |
| This package's source and issues | https://github.com/acryldev/acryl/tree/main/framework (issues) |
| The framework's source | https://github.com/acryldev/acryl (plugins/router, plugins/node-server) |
| For coding agents | https://github.com/acrylblends/acrylblends/blob/main/docs/framework/agents/index.md |
| npm | https://www.npmjs.com/package/acrylblends |
License
MIT. Copyright (c) 2026 WebBoxes s.r.o. The framework is ported from MIT-licensed open-source projects. Their notices are kept in the
package's LICENSE file.
