Documentation Index
Fetch the complete documentation index at: https://docs.bitfield.so/llms.txt
Use this file to discover all available pages before exploring further.
Runtime Kit
Read data in React.
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 boring shape:The mental model
The component asks for data by using the hook. Runtime Kit decides what prepared input 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 does not need to know that path.How it works technically
| Public concept | Meaning |
|---|---|
| Prepared data | Data Runtime Kit has already made available to the app surface. |
| Selector | A public way to pick which prepared input you want. |
data | The current materialized value, or null if none is ready. |
loading | true while Runtime Kit is preparing or waiting for the value. |
error | An Error when the read surface cannot provide the value. |
Import
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 prepared input.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.Render every state
Good Runtime Kit components handle four states.Pair it with a request
Use the hook for reading. UsesendRequestToBitfieldTarget(...) when the user asks something to do work.Before / after
| Before | After |
|---|---|
| Component imports storage helpers. | Component imports one hook. |
| Component chooses low-level data wiring. | Runtime Kit handles preparation behind the surface. |
| Component knows package internals. | Component knows public input names and data shape. |
| AI has many low-level APIs to misuse. | AI gets one read shape and fewer ways to tangle the app. |
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 Runtime Kit internalsOnly import from @bitfield/runtime-kit/react. If code needs private setup machinery, that code is not app component code.Quick reference
Ceiling you have not hit yet
- Replace the source behind a screen: Keep the same input name while changing how Runtime Kit prepares it.
- Build richer package surfaces: Expose multiple named inputs to one component tree without adding more public hooks.
- Keep UI code portable: Wrap the same read idea for another UI stack later.
- Give AI safer rails: Let AI-generated components read prepared values instead of learning private system machinery.