npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ossy/sdk-react

v1.40.3

Published

Software Development Kit React

Readme

React bindings

Thin React layer over @ossy/sdk. One hook — useSdk() — for reads, writes, cache invalidation, and optimistic updates.

Getting started

npm install @ossy/sdk-react @ossy/sdk @ossy/fold
import { WorkspaceProvider, useSdk, AsyncStatus } from '@ossy/sdk-react'
import { ReactSdk } from '@ossy/sdk-react'
import { ListResources, CreateResource } from '@ossy/resources'

const sdk = ReactSdk.of({
  workspaceId: 'your-workspace-id',
  apiUrl: 'https://api.ossy.se/api/v0',
})

export const App = () => (
  <WorkspaceProvider sdk={sdk}>
    <MyComponent />
  </WorkspaceProvider>
)

function MyComponent() {
  const sdk = useSdk()
  const location = '/@ossy/domains/'
  const { status, data: resources, error, refetch } = sdk.read(ListResources, { location })

  const handleCreate = async () => {
    await sdk.invoke(CreateResource, { type: 'document', location, name: 'Hello', content: {} })
    sdk.invalidate(sdk.cacheKey(ListResources, { location }))
  }

  if (status === AsyncStatus.Loading) return <>Loading…</>

  return (
    <>
      <button onClick={handleCreate}>Create</button>
      {resources?.map((r) => <div key={r.id}>{r.name}</div>)}
    </>
  )
}

WorkspaceProvider subscribes to SSE push invalidation automatically (ADR 0008 §9) and drops stale read-cache keys when the server emits invalidate.

API

| Export | Purpose | |---|---| | WorkspaceProvider | Provides SDK + shared read cache + SSE invalidation | | useSdk() | Returns { invoke, invokeOptimistic, read, invalidate, cacheKey, sdk } | | useRead() | Same as sdk.read — hook for reactive reads | | usePushInvalidation() | Wire SSE push to a read-cache store (used by WorkspaceProvider) | | cacheKey(action, payload) | Stable cache key for an action + payload | | projectionKey(projectionId, scopeId) | Cache key for projection reads | | applyOptimisticResource() | Fold a pending event into cached resource state | | rollbackOptimisticResource() | Restore cache entry after failed optimistic invoke | | useReadCacheStore() | Access the shared read-cache store inside <Cache> | | ReactSdk | Browser SDK with invoke and subscribePush | | ActionRef | Platform action POJO type { id, access? } | | resolveActionId() | Normalize dot ids to slash (@ossy.booking.actions.create@ossy/booking/actions/create) | | AsyncStatus | Loading state constants for UI | | normalizeLocation() | Normalize resource location paths | | stableSerialize() | Deterministic JSON for cache keys |

useSdk() shape

const sdk = useSdk()

// Reactive read — re-renders when cache updates
const { status, data, error, refetch } = sdk.read(ListResources, { location })

// Command
await sdk.invoke(CreateResource, payload)

// Optimistic command — folds pending event into cached resource, rolls back on error
await sdk.invokeOptimistic(UpdateResource, payload, {
  type: '@ossy/booking/schema/booking',
  resourceId: 'booking-1',
  event: 'Updated',
  payload: { status: 'confirmed' },
})

// Invalidate cache (triggers re-fetch on next read)
sdk.invalidate('location:/@ossy/domains/')
sdk.invalidate(sdk.cacheKey(ListResources, { location }))

read is a React hook — call it unconditionally at the top of your component (same rules as useState).

Push invalidation

WorkspaceProvider calls usePushInvalidation internally. When the server sends SSE frames with invalidate: string[], matching read-cache keys are cleared and active useRead hooks refetch.

For custom setups, subscribe manually:

import { usePushInvalidation, useReadCacheStore } from '@ossy/sdk-react'

function MyBridge({ sdk }) {
  const store = useReadCacheStore()
  usePushInvalidation(sdk, store)
  return null
}

Requires workspaceId on the SDK config (or same-origin workspace cookie). See @ossy/sdk README.

Cache key conventions

| Action + payload | Cache key | |---|---| | @ossy/resources/actions/list + { location } | location:${normalizeLocation(location)} | | @ossy/resources/actions/search + query | search:${stableSerialize(query)} | | @ossy/resources/actions/get + { resourceId \| id } | resource:${resourceId} | | @ossy/booking/actions/list | action:@ossy/booking/actions/list | | @ossy/platform/actions/list-task-runs + { workspaceId } | projection:@ossy/platform/data/task-run-list:${workspaceId} | | default | action:${actionId} or action:${actionId}:${stableSerialize(payload)} |

Import action POJOs from feature packages (@ossy/resources, @ossy/workspaces, …). Action ids use canonical @ossy/{package}/actions/... notation.

Dependencies

Peer dependencies: @ossy/sdk, @ossy/fold, react, react-dom.

No Ramda.