Render public Casset data in React.
Load /connor, show an honest empty state, and keep the same typed client underneath.
Render /connor
import { createCassetClient } from "@casset/apps"
import {
CassetClientProvider,
useCassetArtist,
useCassetCatalog,
} from "@casset/react"
const client = createCassetClient({
baseUrl: "http://127.0.0.1:3000",
})
function ConnorPage() {
const artist = useCassetArtist("connor")
const catalog = useCassetCatalog("connor")
if (artist.status === "idle" || artist.status === "loading") {
return <p>Loading Connor…</p>
}
if (artist.status === "error") throw artist.error
if (catalog.status === "idle" || catalog.status === "loading") {
return <p>Loading the Catalog…</p>
}
if (catalog.status === "error") throw catalog.error
return (
<main>
<h1>{artist.data.artist.displayName}</h1>
{catalog.data.tracks.length === 0 ? (
<p>No public Tracks yet.</p>
) : (
catalog.data.tracks.map((track, index) => (
<p key={track.kind + "-" + track.title + "-" + index}>{track.title}</p>
))
)}
</main>
)
}
export function App() {
return (
<CassetClientProvider client={client}>
<ConnorPage />
</CassetClientProvider>
)
}Version 0.2.0-alpha.0 is repository-local and vendored into the generated Headless starter. It is not published to npm. Public HTTP examples use a local Casset origin because the deployed public v1 routes are not supported for production use and may intentionally fail closed with 503 ResourceUnavailable. The two public GET routes require no credential; production developer credentials remain unavailable.
Exact exports
| Export | Purpose | Boundary |
|---|---|---|
CassetClientProvider | Provides one existing CassetClient. | Does not create or configure a client. |
useCassetClient() | Reads that client. | Throws if the provider is missing. |
useCassetArtist(handle) | Loads and shares public Artist state by client and handle. | Returns idle, loading, ready, or error plus reload(). |
useCassetCatalog(handle) | Loads and shares public Catalog state by client and handle. | Uses the exact Catalog response; no pagination or filtering is added. |
CassetHostProvider | Provides a Native App host. | Native Apps only; unrelated to Headless HTTP. |
useCassetHostSnapshot() | Reads the host-owned Native App snapshot. | Creates no playback authority. |
CassetQueryResult / CassetQuerySnapshot | Typed query-state unions. | The success state is named ready, not success. |
Query behavior
- Stores are shared per
CassetClientinstance and handle. - An initial effect starts loading; a ready result is reused.
reload()forces a new generation, and the newest generation wins.- Errors remain the SDK's typed errors or an ordinary unexpected
Error. - The adapter does not add caching headers, retries, credentials, endpoint paths, or response fields.
Availability and credentials
Public v1 uses no credential. The local sandbox requires a Bearer value, but that value belongs in the starter's development proxy or another server-side boundary—not in a React prop, context, browser bundle, or log.
See the core SDK, typed errors, and interactive documentation fixture.