Our own projects mirrorless
by Plainweave Systems
Server data as component input, not client-owned application state.
Your server already has state. Your frontend doesn’t need to keep a second, incomplete copy of it. Mirrorless delivers server data to components as plain input, and asks the server again after the commands and events you declare.
- Open source, Apache 2.0
- TypeScript types
- No runtime dependencies
TaskPanel.jsx
<MirrorlessQuery
id="/api/tasks"
loading={LoadingTasks}
>
{(tasks) => <TaskList tasks={tasks} />}
</MirrorlessQuery>
TaskList receives data. It doesn’t own fetching,
loading, subscriptions or a second task database.
The problem
A second world, kept in sync by hand.
It starts as fetched data and grows into a model of the server: collections keyed by id, derived counts, reducers that approximate what the server does. Incomplete, because the client has only some of it. Out of date, because time has passed. Then a command arrives, and every copy needs patching.
a typical write, with a client-side copy
async function completeTask(id) {
await api.completeTask(id)
setTasks((tasks) =>
tasks.map((t) => (t.id === id ? { ...t, done: true } : t)),
)
setActiveTasks((tasks) => tasks.filter((t) => t.id !== id))
setSummary((s) => ({ ...s, done: s.done + 1 }))
// …the open detail pane?
// The “done” filter?
}
the same write, with Mirrorless
// Once, beside your API client
updates: {
CompleteTask: [
'GetTasks',
['GetTask', { id: Symbol.for('id') }],
'GetSummary',
],
}
// In the handler
await runtime.command(
'CompleteTask', { id })
You still say which reads a command can affect. You no longer say how their answers change: the server already knows that.
How it works
Three declarations, no second model.
-
01
Connect the API you have
Two functions: one runs a read, one runs a command. With REST, a read’s name can simply be its GET URL. GraphQL, RPC and existing API clients work too. No server plugin, no wire format.
-
02
Ask for reads where they’re used
A data boundary shows loading or an error until the first answer arrives, then hands your component plain data. Components asking the same question share one request.
-
03
Say what each command affects
Once, as data. After a command succeeds, the affected reads in use are asked again. A timer, window focus or a WebSocket message can run a virtual command that applies the same rules, so live data needs no separate sync layer.
Keep the state that’s actually yours.
Mirrorless doesn’t take away client state. Drafts, selection, open panels and pending flags stay in your framework’s own state. What goes is the hand-maintained copy of the server.
| Value | Who owns it |
|---|---|
Tasks from /api/tasks |
The server, delivered |
The summary from /api/summary |
The server, delivered |
| The selected task’s id | Your component |
| A title not yet submitted | Your component |
| Whether a save is pending | Your component |
Works with
One model, in your framework’s idiom.
Render props, slots, snippets, signals or controllers, depending on the framework. Frameworks are optional peer dependencies: import only the adapter you use.
-
React & React Native
mirrorless/reactProvider, data boundary, hooks
React 18+ -
Vue
mirrorless/vuePlugin, composable, scoped-slot boundary
Vue 3.3+ -
Svelte
mirrorless/svelteContext, readable resource, snippet boundary
Svelte 5+ -
Angular
mirrorless/angularDependency injection and signal queries
Angular 19+ -
Solid
mirrorless/solidContext, query accessor, data boundary
Solid 1.8+ -
Preact
mirrorless/preactProvider, data boundary, hooks
Preact 10.24+ -
Lit
mirrorless/litReactive controller
Lit 3+ -
Plain JS & TypeScript
mirrorless/domData binding with explicit clean-up
No framework
The same task list in
Vue
<MirrorlessQuery id="/api/tasks">
<template #loading><p>Loading…</p></template>
<template #default="{ data }">
<TaskList :tasks="data" />
</template>
</MirrorlessQuery>
Svelte
<MirrorlessQuery id="/api/tasks">
{#snippet loading()}<p>Loading…</p>{/snippet}
{#snippet children(tasks)}
<TaskList {tasks} />
{/snippet}
</MirrorlessQuery>
Angular
readonly tasks = injectMirrorlessQuery<Task[]>('/api/tasks')
// In the template
@if (tasks.ready()) {
<task-list [tasks]="tasks.data() ?? []" />
} @else if (tasks().status === 'error') {
<p role="alert">Tasks are unavailable.</p>
} @else {
<p>Loading…</p>
}
Lit
private readonly tasks = new MirrorlessController<Task[]>(this, {
runtime,
id: '/api/tasks',
})
render() {
const { data, status } = this.tasks.snapshot
if (data !== undefined)
return html`<task-list .tasks=${data}></task-list>`
return status === 'error'
? html`<p role="alert">Tasks are unavailable.</p>`
: html`<p>Loading…</p>`
}
Plain JS
const binding = bindQuery({
runtime,
id: '/api/tasks',
loading: () => { list.textContent = 'Loading…' },
error: () => { list.textContent = 'Tasks are unavailable.' },
render: (tasks) => renderTaskList(list, tasks),
})
// When the view goes away
binding.dispose()
Versions are the supported minimums. The 0.1 release was tested with React 19, Vue 3.5, Svelte 5, Angular 22, Solid 1.9, Preact 10.29 and Lit 3; older versions in range weren’t tested separately. React Native uses the React adapter and hasn’t been tested on a device. What was verified
Is it for you
A smaller contract, not universal magic.
A good fit when
- The server is the source of truth, and the frontend shows and changes its answers.
- Several views show overlapping data, and keeping them right after writes is where your bugs live.
- You have a REST, GraphQL or RPC API you can’t or don’t want to change.
- You’d rather ask the server again than reproduce its rules in the client, even if that means more requests.
Probably not when
- The app is an offline-first or local-first world that users edit independently of the server.
- Its state is genuinely local, as in an editor or a simulation.
- You need server-rendered data handed over to the client: there is no automatic hydration.
- You rely on devtools, infinite-scroll helpers or a persisted cache today.
What it won’t do, on purpose
- Retry failed reads or commands automatically.
- Patch server data optimistically. Show pending work as pending instead.
- Work out what a command affects. You declare it, and can start broad.
- Promise that separate reads form one consistent snapshot.
Already using a query cache?
Libraries such as TanStack Query, SWR and Apollo Client can already refetch after a mutation. Mirrorless draws the line differently: a command’s effects are declared once, centrally, as data, and nothing refreshes unless a declared command or a signal you connected says so. That includes staleness: a view you return to within its interest lease (two minutes by default) shows the last answer without asking again, so connect a focus or timer signal if that’s too old.
Mature caches offer things a 0.1 release doesn’t, such as devtools, pagination helpers, persistence or hydration, depending on the library. Switching is a choice of programming model, not an upgrade.
Migrating one feature at a timeGet started
Try it on one feature first.
Pick one read, the component that shows it, one command, and one other read that command affects: a task list and a separately loaded summary, say. If that works with no patches and no parent coordinating requests, migrate the next feature.
-
01 Install
npm install mirrorlessNative ESM with TypeScript declarations; Node.js 20.19 or later. Install your framework separately. -
02 Connect your API
runtime.js
import { createMirrorless } from 'mirrorless' async function request(url, options = {}) { const response = await fetch(url, options) const body = response.status === 204 ? null : await response.json() if (!response.ok) throw new Error(body?.error ?? `HTTP ${response.status}`) return body } export const runtime = createMirrorless({ query: (url, _params, { signal }) => request(url, { signal }), command: (url, body, { signal }) => request(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body), signal, }), updates: { '/api/tasks': ['/api/tasks', '/api/summary'], refresh: ['/api/tasks', '/api/summary'], }, virtualCommands: ['refresh'], })- Reads are GET URLs; commands are POSTs, here to the same URL. The first rule says a successful POST affects the list and the summary. Failed requests must throw.
-
refreshis a virtual command. Callingruntime.command('refresh')from a timer, focus or socket handler applies the same rule without sending a request. -
URL names match exactly: a filtered read such as
/api/tasks?status=doneneeds its own entry. - A module-level runtime suits a browser-only app. With server rendering, create one per request or session.
-
03 Render plain data
App.jsx
import { MirrorlessProvider, MirrorlessQuery, useMirrorlessRuntime, } from 'mirrorless/react' import { runtime } from './runtime.js' import { LoadingTasks, TaskList } from './tasks.jsx' function AddTask() { const mirrorless = useMirrorlessRuntime() async function submit(event) { event.preventDefault() const form = event.currentTarget const title = new FormData(form).get('title') await mirrorless.command('/api/tasks', { title }) form.reset() } return ( <form onSubmit={submit}> <input name="title" /> <button>Add task</button> </form> ) } export function App() { return ( <MirrorlessProvider runtime={runtime}> <AddTask /> <MirrorlessQuery id="/api/summary"> {(summary) => <p>{summary.done} of {summary.total} done</p>} </MirrorlessQuery> <MirrorlessQuery id="/api/tasks" loading={LoadingTasks}> {(tasks) => <TaskList tasks={tasks} />} </MirrorlessQuery> </MirrorlessProvider> ) }After the POST succeeds, both reads are asked again. There’s no setTasksand no summary counter to keep right. A real form would also track pending and failed submissions in local state.
Or run the demos
The repository has the same task app in eight renderers, with interchangeable Node, Python and Go demo servers. Turn on the timer, change a task from outside, and watch every view catch up. The demo toolchain needs Node.js 24 (24.15 or later).
git clone https://github.com/plainweave-systems/mirrorless.git
cd mirrorless && npm install
npm run demo:server # a local task API; leave it running
# In a second terminal:
npm run demo:react # or demo:vue, demo:svelte…
Made by Plainweave Systems
Questions, bugs, or a migration in mind?
We build and maintain Mirrorless. It’s a 0.x release, so the API may still change. Bug reports and questions are welcome on GitHub. If you’d like help moving a real feature across, that’s the kind of work we do.