React Setup
Using ctrodb with React
React bindings are included in the main package — no separate install needed.
import { useQuery, useDoc, useMutation } from "ctrodb/react"
DatabaseProvider
Wrap your app to make the database available to hooks:
import { DatabaseProvider } from "ctrodb/react"
const db = new Database({ ... })
await db.connect()
export default function App() {
return (
<DatabaseProvider db={db}>
<Todos />
</DatabaseProvider>
)
}
setDefaultDatabase (deprecated)
Deprecated: Use
<DatabaseProvider>instead. Will be removed in v2.0.
If you cannot use a provider, set the default database globally:
import { setDefaultDatabase } from "ctrodb/react"
setDefaultDatabase(db)
// All hooks will use this database instanceHow is this guide?
Last updated on Jul 2, 2026