refract v0.1 · beta
Adapters / Adapter ecosystem

Adapter ecosystem

Adapters are the extension point, and they're packages, not plugins. Core (@theme-registry/refract) ships zero adapter implementations — even the first-party CSS adapter is its own package (@theme-registry/refract-css). Every adapter, first-party or community, is a standalone package that depends on refract for the contract. First-party and contributed adapters have the identical shape, so the ecosystem grows without touching core.

How adapters are packaged

KindWhere it lives
CSS (default)Its own first-party package — @theme-registry/refract-css, depending on refract for the contract (same shape as every other adapter). Core ships no adapter.
Official adaptersSeparate @theme-registry packages (SCSS, JSON, styled-components), each depending on refract and carrying its own peers.
Community adaptersAny scope — a standalone package that imports defineAdapter and the contract types from refract. Consumers wire it in their createTheme / config; nothing registers with core.

There's no registry to publish to and no core change to make — an adapter is just a package that returns a ThemeAdapter. A consumer's createTheme(raw, { adapter: createYourAdapter() }) (or a build-config import) is the wiring. This is the same seam Rollup/Vite/PostCSS use for their plugins.

Quality checklist

A well-behaved adapter, so a theme is portable across it and the built-ins:

Expectation
contractBuilt with defineAdapter — implements the four primitives; lets core fill the aggregators.
statesDeclares allowedStates for the states your format supports (or omits it to accept any) — so recipe state: refs validate correctly.
emit modesIf it supports build-time emit, honors the modes it can and throws a clear error for the ones it can't — never emits silently-wrong output.
namingFollows the token-path model — derive names from the path so output is predictable and consistent with the text adapters where it makes sense.
typesShips its own .d.ts, including its options type — the consumer configures it typed, like CssAdapterOptions.
no core forkDepends on refract for the contract; adds no runtime requirement on core internals beyond the public ThemeAdapter / AdapterSpec surface.

Contributing

refract is early — the fastest ways to help: build an adapter for a format you need (React Native, Compose, a design-token pipeline) and share it; file precise error-message or docs issues; or contribute a preset. The Writing an adapter page is the technical starting point.

Building an adapter is the same shape whether it's official or third-party — the defineAdapter contract is the whole API. A default starter theme package is on the way — see Project status.
Technical documentation for @theme-registry/refract · all output is compiled client-side by the real library (CSS adapter). The chrome is theme-aware; the render panes carry each preset's own world. · MIT licensed.