Files
agent-skills/skills/vueuse-functions/references/useRTDB.md
Jason Woltje f5792c40be feat: Complete fleet — 94 skills across 10+ domains
Pulled ALL skills from 15 source repositories:
- anthropics/skills: 16 (docs, design, MCP, testing)
- obra/superpowers: 14 (TDD, debugging, agents, planning)
- coreyhaines31/marketingskills: 25 (marketing, CRO, SEO, growth)
- better-auth/skills: 5 (auth patterns)
- vercel-labs/agent-skills: 5 (React, design, Vercel)
- antfu/skills: 16 (Vue, Vite, Vitest, pnpm, Turborepo)
- Plus 13 individual skills from various repos

Mosaic Stack is not limited to coding — the Orchestrator and
subagents serve coding, business, design, marketing, writing,
logistics, analysis, and more.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 16:27:42 -06:00

71 lines
1.5 KiB
Markdown

---
category: '@Firebase'
---
# useRTDB
Reactive [Firebase Realtime Database](https://firebase.google.com/docs/database) binding. Making it straightforward to **always keep your local data in sync** with remotes databases.
## Usage
```ts
import { useRTDB } from '@vueuse/firebase/useRTDB'
import { initializeApp } from 'firebase/app'
import { getDatabase } from 'firebase/database'
const app = initializeApp({ /* config */ })
const db = getDatabase(app)
// in setup()
const todos = useRTDB(db.ref('todos'))
```
You can reuse the db reference by passing `autoDispose: false`
```ts
const todos = useRTDB(db.ref('todos'), { autoDispose: false })
```
or use `createGlobalState` from the core package
```ts twoslash include store
// @filename: store.ts
// ---cut---
// store.ts
import { createGlobalState } from '@vueuse/core'
import { useRTDB } from '@vueuse/firebase/useRTDB'
export const useTodos = createGlobalState(
() => useRTDB(db.ref('todos')),
)
```
```vue
<!-- app.vue -->
<script setup lang="ts">
// @include: store
// ---cut---
import { useTodos } from './store'
const todos = useTodos()
</script>
```
## Type Declarations
```ts
export interface UseRTDBOptions {
errorHandler?: (err: Error) => void
autoDispose?: boolean
}
/**
* Reactive Firebase Realtime Database binding.
*
* @see https://vueuse.org/useRTDB
*/
export declare function useRTDB<T = any>(
docRef: DatabaseReference,
options?: UseRTDBOptions,
): Ref<T | undefined, T | undefined>
```