Skip to main content

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.

Reference

Runtime Kit API.

The current public JavaScript Runtime Kit API exposes one request function and one React read hook.

Public imports

import {
  sendRequestToBitfieldTarget,
  type BitfieldTargetReply,
  type BitfieldTargetRequest,
} from '@bitfield/runtime-kit';
import { useBitfieldData } from '@bitfield/runtime-kit/react';
The request and reply types are exported from @bitfield/runtime-kit. The React hook exports the hook value only.

sendRequestToBitfieldTarget(...)

function sendRequestToBitfieldTarget(
  request: BitfieldTargetRequest,
  signal?: AbortSignal,
): Promise<BitfieldTargetReply>;

Request

type BitfieldTargetRequest = {
  target: string;
  payload?: unknown;
};
FieldRequiredMeaning
targetyesPublic name of the callable target.
payloadnoData sent to the target. Runtime Kit turns it into bytes.

Reply

type BitfieldTargetReply = {
  payload: Uint8Array;
};
The reply is bytes. Decode it according to the target contract.

Payload conversion

InputSent as
Uint8ArrayThe same bytes.
stringText bytes.
Any other JSON-compatible valueJSON bytes.
omittedEmpty bytes.

Errors

The function throws an Error if the request cannot complete. App code should catch errors at user-action boundaries and render a recoverable state.

Guide

Read Send a request for examples and patterns.

useBitfieldData(...)

function useBitfieldData<T>(
  selector?:
    | string
    | {
        input?: string;
        params?: Record<string, unknown>;
      },
): {
  data: T | null;
  loading: boolean;
  error: Error | null;
};

Return value

FieldMeaning
dataThe current prepared value, or null if no value is ready.
loadingtrue while Runtime Kit is preparing or waiting for the value.
errorThe read error, or null when no error exists.

Selector forms

SelectorMeaning
omittedRead the default prepared input for this surface.
stringRead a named prepared input.
object with input and paramsRead a named or selected input with local selection params.
Selector names are app-surface names. They are not storage paths. Do not import React selector helper types from unpublished paths.

Guide

Read Read data in React for component examples and common mistakes.

Public versus private

Public app code may useApp code should not use
@bitfield/runtime-kitUnpublished Runtime Kit source paths.
@bitfield/runtime-kit/reactPrivate setup or low-level Runtime Kit machinery.
sendRequestToBitfieldTarget(...)Direct imports of the target implementation.
useBitfieldData(...)Hand-built storage addresses or package parsing inside components.
This boundary is deliberate. Runtime Kit can improve the machinery behind the public surface without making app code change every time.

Version note

This page documents the current public JavaScript surface. If the package exports change, this reference and the Runtime Kit guides must be reviewed together.
Last modified on May 9, 2026