BijectionClient with
declarative subscriptions for Svelte 5, so your frontend
code can:
- Receive live updates to your queries with automatic reactivity
- Call your mutations and actions
- Paginate through large datasets
- Authenticate users
- Server-side render data in SvelteKit
Source & issuesSource: bijectionhq/bijection-svelte.
Found a bug or have a feature request? Open an issue in its issue tracker.
Found a bug or have a feature request? Open an issue in its issue tracker.
Installation
Install the Bijection CLI, then add a Bijection backend to your SvelteKit app from its root directory:src/, so move the Bijection
functions directory there and point bijection.json at it:
bijection.json
bijection/react, bijection/browser, …) is not published
to the npm registry. Your app declares it as a tarball from bijection.com, for
the version of your CLI (bijection --version prints it). Add this line to the
dependencies in your app’s package.json:
package.json
npm install). The react-vite and nextjs templates of
bijection init write this line and run the install for you.
Also add bijection-svelte to your app with your package manager.
Log in once per machine and set up a Bijection dev deployment:
bijection dev creates your dev deployment and saves its URL
in .env.local as PUBLIC_BIJECTION_URL.
Setup
CallsetupBijection() once in a root layout component (e.g. +layout.svelte).
This initializes a BijectionClient and
stores it in Svelte context so child components can access it. The client is
app-scoped: it stays open for the lifetime of the app (remounts and HMR reuse
the same connection) and supports a single deployment URL. For explicit teardown
— e.g. in tests — call closeBijection().
src/routes/+layout.svelte
setupBijection() returns the BijectionClient instance, which you can use directly
in the layout for mutations or actions (e.g. an auth nav bar). In child
components and .ts files, use getBijectionClient() to retrieve it — see
Client access.
You can pass BijectionClientOptions as the second argument to configure the
BijectionClient.
Non-SvelteKit usageIf you’re using plain Vite + Svelte (no SvelteKit), replace
$env/static/public
with import.meta.env.VITE_BIJECTION_URL and set VITE_BIJECTION_URL in your .env
file.Fetching data
UseuseQuery() to subscribe to a Bijection query with automatic real-time
updates. When the data changes on the server, your component re-renders
automatically.
src/routes/+page.svelte
Next steps
- Queries, Mutations & Actions — the core reactive API
- Authentication — wire up auth providers
- SvelteKit Server Rendering —
SSR with
bijectionLoad - Why server-side rendering with Bijection? — performance deep dive
- Troubleshooting — common errors and fixes