signal
signal<
T>(defaultValue,options?):SignalDef<T>
Defined in: packages/@livestore/livestore/src/live-queries/signal.ts:51
Creates a reactive signal for ephemeral, local-only state that isn’t persisted to the database.
Signals are useful for UI state that needs to trigger query re-evaluation but shouldn’t be synced across clients or stored permanently—such as search filters, selected items, or temporary form values.
Unlike database-backed state (via events), signals:
- Are not persisted or synced
- Exist only for the lifetime of the Store
- Can hold any value type (primitives, objects, functions)
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”defaultValue
Section titled “defaultValue”T
Initial value of the signal
options?
Section titled “options?”label?
Section titled “label?”string
Human-readable label for debugging and devtools
Returns
Section titled “Returns”SignalDef<T>
A signal definition that can be used with store.query(), store.setSignal(), and as a dependency in other queries
Examples
Section titled “Examples”// Create a signal for search textconst searchText$ = signal('', { label: 'searchText' })
// Create a query that depends on the signalconst filteredTodos$ = queryDb( (get) => tables.todos.where({ text: { $like: `%${get(searchText$)}%` } }), { deps: [searchText$] })
// Update the signal (triggers query re-evaluation)store.setSignal(searchText$, 'buy')
// Read the current valueconst results = store.query(filteredTodos$)// Counter with functional updatesconst count$ = signal(0, { label: 'count' })
store.setSignal(count$, (prev) => prev + 1)