Query Reference
@svelte-lean/query/tabs
tabs(): one tab polls each polled entry and holds the live connection (Web Locks); the others receive invalidations, changed values and live events over a BroadcastChannel, per scope and session.
Markdown version of this page, for assistants (Markdown for AI)
Note ./tabs is experimental: the API can still change in a minor release.
Stability per entry point: Entry points.
On this page
Import
import { tabs } from '@svelte-lean/query/tabs';Usage
// src/lib/api/modules.ts
import { tabs } from '@svelte-lean/query/tabs';
import { session } from '$api/session.svelte';
// Tabs of the same user share one poller and one live connection; another login never hears them.
export const crossTab = tabs({
session: () => (session.userId === null ? null : String(session.userId))
});Size
Production Vite builds of a small consumer entry, Svelte external. A marginal row is the bytes the entry adds over the row it names.
| Build | Over | gzip | brotli | Budget (gzip) |
|---|---|---|---|---|
tabs (marginal) | query | 3104 B | 2874 B | 3500 B |
Read from packages/query/artifacts/size.json. Every entry and its method: Performance.
Functions
One module; no call site changes.
Exports
Runtime exports of the entry.
| Name | Type | Default | Description |
|---|---|---|---|
# tabs | (init?: TabsInit) => Module | – | Cross-tab coordination. Without BroadcastChannel or Web Locks every tab works alone. |
Options
TabsInit, the argument of tabs().
TabsInit
All optional.
| Name | Type | Default | Description |
|---|---|---|---|
# name | string | 'slq' | Namespace of the channel and lock names. |
# session | () => string | null | – | Reactive partition beside the scope (a user id): tabs of another session never share. null: this tab works alone. |
# share | number | false | 16384 | Largest value (JSON text length) sent with a changed entry; above it the receiving tab refetches. false: never. |
Guide
How to use it, with examples: Realtime. All entry points: Svelte Lean Query.