Migrating from 0.1.x
brust 2 is a rewrite. 0.1.x lives on the main branch as brustjs; 2.x is @brust/core. Most app code moves over with renamed imports and fewer route fields.
Packages and imports
$ bun remove brustjs
$ bun add @brust/core| 0.1.x | 2.x |
|---|---|
brustjs (binary brustjs) | @brust/core (binary brust) |
brustjs/routes | @brust/core/routes |
brustjs/store | @brust/core/store, and @brust/core/store/react for useStore |
brustjs/client | @brust/core/client (the Eden actions client) |
Routes
A route has exactly five fields now: path, Component, loader, cache, children. Switch between the two versions of the pokedex's routes:
The pokedex example on 0.1.x (branch main): every route opts in with native: true.
import { defineRoutes } from 'brustjs/routes'
import AppLayout from './components/AppLayout'
import { browseLoader, detailLoader, homeLoader } from './lib/loaders'
import BrowsePage from './pages/BrowsePage'
import DetailPage from './pages/DetailPage'
import HomePage from './pages/HomePage'
export const routes = defineRoutes([
{
Component: AppLayout,
native: true,
children: [
{ path: '/', Component: HomePage, native: true, loader: homeLoader },
{ path: '/pokedex', Component: BrowsePage, native: true, loader: browseLoader },
{ path: '/pokemon/{name}', Component: DetailPage, native: true, loader: detailLoader },
],
},
])The same routes on 2.x: the compiler decides per component, so native: true is gone (and now fails the build).
import { defineRoutes } from '@brust/core/routes'
import AppLayout from './components/AppLayout'
import { browseLoader, detailLoader, homeLoader } from './lib/loaders'
import BrowsePage from './pages/BrowsePage'
import DetailPage from './pages/DetailPage'
import HomePage from './pages/HomePage'
export const routes = defineRoutes([
{
Component: AppLayout,
children: [
{ path: '/', Component: HomePage, loader: homeLoader },
{ path: '/pokedex', Component: BrowsePage, loader: browseLoader },
{ path: '/pokemon/{name}', Component: DetailPage, loader: detailLoader },
],
},
])Also rejected now: errorBoundary, ssg, middleware, sse, websocket, cache.key and cache.key_ttl_seconds.
CLI
brustjs newis nowbun create @brust/app.brustjs dev(watch and reload) has no Bun equivalent:brust devis the Cloudflare loop. Usebun run devto build and start.--targetnow meansbunorcloudflare, not a native binary platform.--ssgis gone.
What is gone
native: trueroutes and hand-writtenx-*behaviors: every component is compiled, andx-*attributes are now compiler output.- Markdown pages (
mdRoutes,mdNav) and static generation. - The
window.BrustAI runtime.
brust.toml
[cache] max_entriesandpage_max_entriesare unknown keys now:[cache]configures a cache adapter.BRUST_AI,BRUST_CACHE_SYNC_URLandBRUST_CACHE_SYNC_CHANNELare gone.BRUST_ADDR,BRUST_PORTandBRUST_WORKERSmean what they meant.
The actions client
The 0.1.x client was hand-made; the 2.x one is Eden Treaty, and its behavior is not shimmed back:
- A network failure resolves with status 503, not 0.
headersis aHeadersobject, not a plain record.- Path params are
encodeURIComponent-ed:item(({ id: "a b/c" }))requests/item/a%20b%2Fc.
Cross-site action requests are rejected by default in 2.x (cross_site = "reject"). Set it to "allow" only if another site must call your actions.