Skip to main content

Use useBitfieldData(...) when a React component needs data that Runtime Kit has already prepared for that surface.

What this is

useBitfieldData(...) is the public React read hook. It gives a component one consistent return shape:
That shape is the point. Your component can render data, loading, and error states without importing the code that prepared the data.

The mental model

The component asks for data by using the hook. Runtime Kit decides what data name that component is allowed to read. The component receives the latest app-facing value.This is not a normal fetch call. The component is not asking a server for a record by URL. It is reading a prepared app value. Runtime Kit may prepare that value from local data, package records, package-owned bytes, derived values, or another public package surface. The component should not import that preparation path.

How it works technically

The public hook call is stable even when Runtime Kit changes how it prepares the value.For the exact selector forms, return-state contract, and invalid examples, read Runtime Kit API.

Import

Do not import from unpublished Runtime Kit paths. The public React package exports the hook.

Read the default input

Use the hook without an argument when the surface has one default prepared value.

Read a named input

Use a string selector when the surface exposes more than one data name.
The string is not a storage path. It is a public input name made available to this surface.

Read with local params

Some surfaces may allow a selection object with params. Params are local selection data, like the current search query or selected item id.
Use params for the user selection on this screen. Do not use params to smuggle private storage or setup into a component.

Render every state

Good Runtime Kit components handle four states.
That sounds simple because it should be simple. Runtime Kit owns the preparation work.

Pair it with a request

Use the hook for reading. Use sendRequestToBitfieldTarget(...) when the user asks something to do work.
The request asks a target to do work. The hook reads prepared results.

Before / after

Common mistakes

Using the hook as setup codeDo not make the component create package state, storage addresses, or low-level wiring. The component reads prepared app data.Skipping loading and empty statesdata can be null. Treat that as a real state, not an error.Assuming every selector is globalA selector is scoped to the surface that Runtime Kit prepared. If a selector is not available, fix the package/surface boundary instead of hardcoding private reads in the component.Deep importing unpublished Runtime Kit codeOnly import from @bitfield/runtime-kit/react. If code needs private setup machinery, that code is not app component code.

Quick reference

Return shape:

Now build the bigger version

Build a real screen with two data names and one request.
The component is doing real work, but it still only uses data names, an action name, and public payload shapes.
Last modified on May 10, 2026