jazz-ui-development
Original:🇺🇸 English
Translated
Use this skill when building, debugging, or optimizing Jazz applications. It covers Jazz's bindings with various different UI frameworks, as well as how to use Jazz without a framework. Look here for details on providers and context, hooks and reactive data fetching, authentication, and specialized UI components for media and inspection.
3installs
Sourcegarden-co/jazz
Added on
NPX Install
npx skill4agent add garden-co/jazz jazz-ui-developmentTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Jazz UI Development
When to Use This Skill
- Building user interfaces that display or interact with Jazz data
- Setting up authentication providers and contexts
- Debugging reactivity, data loading, or sync issues in the UI
- Optimizing performance of data subscriptions
- Handling media (images, files) in the UI
Do NOT Use This Skill For
- Defining data schemas (use )
jazz-schema-design - Complex permission logic or sharing workflows (use )
jazz-permissions-security - Testing questions (use )
jazz-testing
Key Heuristic for Agents
Use this skill when the user asks about rendering data, handling user input, managing authentication state, or framework-specific integration (React, Svelte, etc.). If the issue is "data not appearing" but permissions are correct, look here for loading and subscription patterns.
Framework Guides
Select the guide for your specific framework:
- React: React Reference
- React Native (Bare): As well as the React guide, also see React Native Reference
- React Native (Expo): As well as the React guide, also seeReact Native (Expo) Reference
- Svelte: Svelte Reference
- Vanilla JS: Vanilla JS Reference
Universal CoValue API
These APIs are available on all CoValue instances, regardless of the framework.
Core Properties
All CoValues (CoMaps, CoLists, etc.) have these properties directly on the instance:
- (
$isLoaded): Returnsbooleanif the CoValue is fully loaded and ready to read.true - : Returns a plain JavaScript object representation of the CoValue. Use this for debugging only, not for rendering.
.toJSON()
The .$jazz
Namespace
.$jazzEvery CoValue instance has a property containing metadata and utility methods.
.$jazzMetadata
- (
.$jazz.id): The globally unique ID of the CoValue (e.g.,ID<CoValue>).co_zXy... - (
.$jazz.owner): The Group that owns this CoValue. Access control is determined by membership in this group.Group - (
.$jazz.createdAt): Creation timestamp (ms since epoch).number - (
.$jazz.createdBy): ID of the creating account.ID<Account> | undefined - (
.$jazz.lastUpdatedAt): Last update timestamp (ms since epoch).number
Loading & Inspection
- (
.$jazz.loadingState): The current loading state."loading" | "loaded" | "unavailable" | "unauthorized" - : Waits for nested references to load. Returns a promise with a new instance where requested fields are guaranteed available.
.$jazz.ensureLoaded({ resolve: { ... } })
ts
const detailedPost = await post.$jazz.ensureLoaded({
resolve: {
comments: {
$each: {
author: true
}
}
}
});- (CoMap/CoRecord only): Access nested CoValues as references (with IDs) without loading them.
.$jazz.refs - (CoMap/CoRecord only): Checks if a key exists.
.$jazz.has(key)
Subscription & Sync
- : Manually subscribe to changes. Returns an unsubscribe function. Prefer framework-specific hooks (e.g.,
.$jazz.subscribe(callback)) over this.useCoState - : Promise that resolves when changes are synced to peers. Useful for critical saves or logout flows.
.$jazz.waitForSync()
Version Control
- (
.$jazz.isBranched): Whether the CoValue is currently in a local branch.boolean - (
.$jazz.branchName): The name of the current branch.string - : Merges a branch back into the main history.
.$jazz.unstable_merge()
Working with Data Types
CoMap / CoRecord
- Read: Access properties like a standard JS object (e.g., ).
user.name - Write:
.$jazz.set(key, value).$jazz.delete(key).$jazz.applyDiff(diff)
CoList
- Read: Access by index (), iterate (
list[0],map).forEach - Write:
.$jazz.push(item).$jazz.unshift(item).$jazz.splice(...).$jazz.remove(index or predicate)
CoText (CoPlainText / CoRichText)
- Read: or use directly in template.
toString() - Write:
insertAfter(index, text)deleteRange({ from, to }).$jazz.applyDiff(newText)
CoFeed
- Read: Iterate over (returns per-session feeds).
feed.all - Write: (Append-only).
.$jazz.push(item)
ts
// Subscribing to all entries across all accounts
const allEntries = Object.values(feed.perAccount).flatMap(accountFeed => Array.from(accountFeed.all));
// Pushing a new entry
feed.$jazz.push({ message: "Hello", timestamp: Date.now() });DiscriminatedUnion
- Read: Check the discriminator property (e.g. ) to narrow the type.
type - Write: Overwrite the property with a new object of the desired variant.
ts
const list = co.list(MyUnion);
const item = list[0];
if (item.type === "text") {
console.log(item.value); // item is narrowed to TextVariant
} else if (item.type === "image") {
console.log(item.image.$jazz.id); // item is narrowed to ImageVariant
}FileStream
- Read: Use or consume chunks.
toBlob() - Write: Use or
createFromBlob(blobOrFile).start(metadata) -> push(chunk) -> end()
ImageDefinition
- Read: Use component (framework specific) or
<Image>.loadImageBySize - Write: use the function from
createImagejazz-tools/media
tsx
<Image imageId={productImage.$jazz.id} width={300} />Troubleshooting
"Data not appearing" or "Value is undefined"
- Check : Ensure you are checking
$isLoadedbefore rendering.if (coValue.$isLoaded) - Deep Loading: If nested data is missing, use in your hook (e.g.
resolve).useCoState(..., { resolve: { items: true } }) - Provider Check: Ensure the component is wrapped in the appropriate .
<JazzProvider />
"Infinite re-render loops"
- Selector Stability: Ensure your function in
selectis stable or returns stable references.useCoState - Expensive Selectors: Move computations to instead of doing them inside the
useMemofunction.select - Equality Function: Use to prevent unnecessary updates if the selected data hasn't changed semantically.
equalityFn
"Reactivity not triggering"
- Direct Mutations: Ensure you are using or
.$jazz.set()instead of direct property assignment (e.g..$jazz.push()won't sync).obj.key = val - Deep Updates: Remember that updating a nested scalar doesn't trigger a change in the parent CoValue unless that parent property is replaced.