svelte-firebase-state
Firebase utilities for Svelte 5.
Svelte Playground ->NodeState manages a specific node in the Realtime Database, support fetching, live updates and saving changes with optional autosave.
Quick example:
demo
Parameters:
required
database Database
The firebase database instance.
required
path string | ((currentUser: User | null) => string)
The path to the node in the database.
optional
auth Auth
The firebase auth instance.
optional
listen boolean
default = false
Listen for real-time updates.
Properties:
data Data | null | undefined
Reactive state that holds the node data.
The data is undefined when loading.
The data is null when the node could not be found.
Methods:
save (key?: K, update?: DataApp[K] | ((prevValue: DataApp[K]) => DataApp[K])) => Promise<void>
Save changes to the document.
refetch () => Promise<Data>
Re-fetch the data.
More examples:
Listen to a node and save it
demo
Listen to a node and use autosave
demo