Skip to content

v0.4.0

Choose a tag to compare

@gaudiauj gaudiauj released this 27 Mar 21:39
· 16 commits to main since this release

Breaking

  • Page-route document mutations are no longer supported. Non-GET/HEAD requests to page routes now return 405.
  • useActionData has been removed from:
    • react-bun-ssr
    • react-bun-ssr/route
  • SSR action payload plumbing via actionData was removed. Loader payloads remain loaderData-only.

Added

  • First-class server-only route model with *.server.ts / *.server.tsx support for:
    • app/root.server.tsx
    • app/routes/**/_layout.server.tsx
    • page route companions (app/routes/**/page.server.tsx)
    • global middleware (app/middleware.server.ts)
    • nested middleware (app/routes/**/_middleware.server.ts)
    • API route files (app/routes/api/**.server.ts)
  • New createRouteAction<TState>() export in react-bun-ssr/route for direct React 19 form actions:
    • useActionState(action, initialState) where action = createRouteAction<TState>()
  • Internal action endpoint: POST /__rbssr/action?to=... with typed envelopes:
    • data
    • redirect
    • catch
    • error
  • Typed locals augmentation surface:
    • AppRouteLocals (root + route entrypoints)
    • threaded through middleware, loaders, actions, and API handlers
  • Response mutation primitives on request context:
    • ctx.response.headers.set/append/delete
    • ctx.response.cookies.get/set/delete
  • Security helpers:
    • assertSameOriginAction
    • sanitizeRedirectTarget

Changed

  • useRouteAction is still supported and now shares the same action transport path as createRouteAction.
  • Companion merge behavior now allows action in both base + companion only when base action is a marked client stub (createRouteAction).
  • Server runtime strips client action stubs from server-executed modules, preventing accidental server execution of client stubs.
  • Route scanning/build/dev flows treat .server files as server-only and keep them out of client bundling.
  • Dev/runtime behavior now consistently reloads for .server changes in dev paths.

Fixed

  • Bun-only/server-only imports can now live in server companions without leaking into browser bundles.
  • Staged response headers/cookies are committed consistently across plain data, redirects, middleware short-circuits, transition paths, and explicit Response returns.
  • ctx.locals typing now works end-to-end without app-level type-recovery hacks.

Docs

  • Updated framework docs and API docs to the useActionState + createRouteAction model.
  • Updated README, app/public/llms.txt, and AGENTS.md with the new action/server-companion guidance.
  • Regenerated:
    • API docs (app/routes/docs/api/*.md)
    • docs manifest (app/routes/docs/docs-manifest.json)
    • search index (app/routes/docs/search-index.json)

Tests

  • Added/updated unit + integration coverage for:
    • server-only companions and .server route scanning/build behavior
    • action endpoint envelope behavior
    • createRouteAction and useRouteAction compatibility
    • response mutation commit semantics
    • typed locals usage across middleware/loader/action/API
    • page-route mutation 405 behavior and migration path messaging

Migration

  • For page mutations, move to React 19 actions:
    • UI route file: export const action = createRouteAction<TState>()
    • server companion: export const action: Action = async (ctx) => { ... }
    • component: const [state, formAction] = useActionState(action, initialState)
  • Move Bun-only imports into *.server.ts(x) files.
  • Replace useActionData usage with useActionState state handling.
  • useRouteAction can remain temporarily for backward-compatible migrations.