-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathApp.tsx
51 lines (47 loc) · 1.44 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { PGliteWorker } from '@electric-sql/pglite/worker'
import { Repl } from '@electric-sql/pglite-repl'
import { useEffect, useState } from 'react'
import PGWorker from './pglite-worker.js?worker'
import './App.css'
let pgPromise: Promise<PGliteWorker>
function App() {
pgPromise ??= PGliteWorker.create(
new PGWorker({
name: 'pglite-worker',
}),
)
const [pg, setPg] = useState<PGliteWorker | null>(null)
useEffect(() => {
pgPromise.then(setPg)
}, [])
return (
<>
<h1>
<a href="https://pglite.dev">PGlite</a> +{' '}
<a href="https://github.com/electric-sql/pglite/pull/364">
HttpFs
</a>
</h1>
<div className="intro">
<p>
This demo shows how to use <a href="https://pglite.dev">PGlite</a>, a
WASM build of Postgres running entirely in the browser, with the WIP
HttpFs to connect to a remote PGlite database. It's using HTTP range
requests to fetch database file pages from the remote server on
demand.
</p>
<p>
The database in this demo is the{' '}
<a href="https://github.com/devrimgunduz/pagila">Pagila</a> sample
database.
</p>
<p>
The REPL below supports the same <code>\d</code> commands as{' '}
<code>psql</code>.
</p>
</div>
{pg ? <Repl pg={pg} border={true} /> : <p>Loading...</p>}
</>
)
}
export default App