React SDK
Build reactive Foundry apps with @osdk/react hooks backed by one shared, normalized cache.
Foundry docsOSDK React applications
@osdk/react wraps the OSDK client in hooks. Every hook reads from one normalized cache, so a list, a detail view, and a link panel that show the same object stay in sync, and an action updates them all without manual refetching.
import { useOsdkObjects } from "@osdk/react";
import { Employee } from "@my-app/sdk";
export function EmployeeList() {
const { data, isLoading, error } = useOsdkObjects(Employee, {
where: { department: "Engineering" },
orderBy: { fullName: "asc" },
});
return (
<section aria-busy={isLoading}>
{error != null && <p role="alert">Could not load employees.</p>}
<ul>
{data?.map((employee) => (
<li key={employee.$primaryKey}>{employee.fullName}</li>
))}
</ul>
</section>
);
}New to OSDK? Start with the Quickstart, then create a client and add OsdkProvider.
Hooks
| Hook | Use it to | Guide |
|---|---|---|
useOsdkObjects | Load a list of objects with filters, sorting, and paging | Query objects |
useOsdkObject | Load one object by primary key | Query objects |
useLinks | Load the objects linked to an object | Follow links |
useObjectSet | Combine, intersect, subtract, or pivot object sets | Work with object sets |
useStableObjectSet | Keep an object set referentially stable across renders | Work with object sets |
useOsdkAggregation | Count, sum, average, and group on the server | Aggregate data |
useOsdkAction | Apply and validate actions | Apply actions |
useDebouncedCallback | Debounce validation while a user types | Apply actions |
useOsdkFunction, useOsdkFunctions | Call Ontology functions with caching | Call functions |
useObservableClient | Invalidate cached data by hand | Invalidate the cache |
useOsdkClient | Get the client for one-off, imperative calls | Create a client |
useOsdkMetadata | Read object and action type metadata | Reference |
User, group, and marking hooks live in @osdk/react/platform-apis; see Users and markings. Test utilities live in @osdk/react/testing; see Test your app.