Skip to content

Commit 13f20c2

Browse files
committed
Update readme
1 parent 2c399ff commit 13f20c2

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

icechunk-js/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,22 @@ In-memory storage works on all platforms. The following backends are available o
4646
- **HTTP**`Storage.newHttp(baseUrl, config?)`
4747
- **Local Filesystem**`Storage.newLocalFilesystem(path)`
4848

49+
### Fetch Storage (read-only, works everywhere)
50+
51+
For read-only access to a publicly hosted Icechunk repository, use the built-in fetch-based storage. This works on both native and WASM builds, making it the easiest way to open a repository in the browser:
52+
53+
```typescript
54+
import { Repository } from '@earthmover/icechunk'
55+
import { createFetchStorage } from '@earthmover/icechunk/fetch-storage'
56+
57+
const storage = createFetchStorage('https://my-bucket.s3.us-west-2.amazonaws.com/my-repo.icechunk')
58+
const repo = await Repository.open(storage)
59+
const session = await repo.readonlySession({ branch: 'main' })
60+
const keys = await session.store.list()
61+
```
62+
63+
The repository must be on S3-compatible storage with public read access and XML listing enabled. `createFetchStorage` uses the browser `fetch` API under the hood, so it works in any environment where `fetch` is available.
64+
4965
### Custom Storage Backends
5066

5167
For WASM builds (or any environment where the built-in backends aren't suitable), you can provide your own storage implementation in JavaScript using `Storage.newCustom()`:
@@ -86,6 +102,18 @@ Install the package with the `--cpu=wasm32` flag to get the WASM binary:
86102
npm install @earthmover/icechunk --cpu=wasm32
87103
```
88104

105+
To open a public repository in the browser, use fetch storage:
106+
107+
```typescript
108+
import { Repository } from '@earthmover/icechunk'
109+
import { createFetchStorage } from '@earthmover/icechunk/fetch-storage'
110+
111+
const storage = createFetchStorage('https://my-bucket.s3.us-west-2.amazonaws.com/my-repo.icechunk')
112+
const repo = await Repository.open(storage)
113+
```
114+
115+
For more control, use `Storage.newCustom()` to implement your own storage backend with any JS networking library.
116+
89117
The WASM build uses `SharedArrayBuffer` for threading, which requires your server to send these headers:
90118

91119
```

0 commit comments

Comments
 (0)