Skip to content

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)

T

T

Initial value of the signal

string

Human-readable label for debugging and devtools

SignalDef<T>

A signal definition that can be used with store.query(), store.setSignal(), and as a dependency in other queries

// Create a signal for search text
const searchText$ = signal('', { label: 'searchText' })
// Create a query that depends on the signal
const 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 value
const results = store.query(filteredTodos$)
// Counter with functional updates
const count$ = signal(0, { label: 'count' })
store.setSignal(count$, (prev) => prev + 1)