Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

indexeddb.tsx

37 lines999 Bytes

1import { createFileRoute } from '@tanstack/react-router'
2import { useEffect, useState } from 'react'
3import { TodoDemo } from '~/components/TodoDemo'
4import { createIndexedDBOfflineExecutor } from '~/db/todos'
5​
6export const Route = createFileRoute(`/indexeddb`)({
7 component: IndexedDBDemo,
8})
9​
10function IndexedDBDemo() {
11 const [offline, setOffline] = useState<any>(null)
12​
13 useEffect(() => {
14 let offlineExecutor: any
15​
16 createIndexedDBOfflineExecutor().then((executor) => {
17 offlineExecutor = executor
18 console.log({ offlineExecutor })
19 setOffline(executor)
20 })
21​
22 return () => {
23 offlineExecutor?.dispose()
24 }
25 }, [])
26​
27 return (
28 <div className="min-h-screen bg-gray-100 py-8">
29 <TodoDemo
30 title="IndexedDB Storage Demo"
31 description="Persistent offline storage with IndexedDB. Data survives browser restarts and provides the best offline experience."
32 storageType="indexeddb"
33 offline={offline}
34 />
35 </div>
36 )