docs

Simple enough to scan. Deep enough to ship with.

Start here if you want the short version first. The sidebar walks through setup, core APIs as small building blocks, examples, hooks, and the heavier reference material — open whichever page answers your question.

what this page covers
  • How to install, wrap, and declare your first resource or action.
  • The three-step setup path to a working demo.
  • Where to go next for API reference, examples, and advanced topics.

quick start

#

Set it up in three moves

Each step does one job so the first pass stays easy to follow.

1. Install

Add the package and let the Vite plugin keep the service worker in sync.

setup.ts
npm install @sweidos/eidos
import { eidos } from '@sweidos/eidos/vite'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [eidos()],
})

2. Wrap the app

Mount the provider once at the root so the runtime can register the SW.

main.tsx
import { createRoot } from 'react-dom/client'
import { EidosProvider } from '@sweidos/eidos'
import { App } from './App'
const root = createRoot(document.getElementById('root')!)
root.render(
<EidosProvider swPath="/eidos-sw.js">
<App />
</EidosProvider>
)

3. Declare intent

Keep resources and actions at module scope so replay can find them later.

src/lib/eidos.ts
import { resource, action } from '@sweidos/eidos'
export const products = resource('/api/products', { offline: true })
export const createOrder = action(
async (payload: OrderPayload) => {
const res = await fetch('/api/orders', {
method: 'POST',
body: JSON.stringify(payload),
})
return res.json()
},
{ reliability: 'neverLose', name: 'createOrder' },
)

Use this page when...

A short checklist keeps the page from feeling like a wall of text.

  • You want the shortest path from install to a working demo.
  • You need a refresher on the three-step setup.
  • You are ready to move on to API reference or examples.