Skip to main content

Threaded Browser Package API

This page covers the primadb/threads entrypoint. It extends the browser runtime with thread bootstrap helpers and still shares the same core runtime classes documented on the browser runtime page.

This page is generated from the current package source declarations.

packages/primadb/threads.ts

Primary primadb/threads entrypoint.

Direct exports

PrimadbThreadsInitInput

Kind: type alias

export type PrimadbThreadsInitInput = Parameters<typeof initWasm>[0];

PrimadbThreadsInitOutput

Kind: type alias

export type PrimadbThreadsInitOutput = Awaited<ReturnType<typeof initWasm>>;

ThreadedPrimadbInitOptions

Kind: interface

export interface ThreadedPrimadbInitOptions {
input?: PrimadbThreadsInitInput;
threads?: number;
}

suggestedThreadCount

Kind: function

export declare function suggestedThreadCount(fallback?: number): number;

initPrimadbThreads

Kind: function

export declare function initPrimadbThreads(input?: PrimadbThreadsInitInput): Promise<PrimadbThreadsInitOutput>;

bootstrapPrimadbThreads

Kind: function

export declare function bootstrapPrimadbThreads(options?: ThreadedPrimadbInitOptions): Promise<PrimadbThreadsInitOutput>;

createThreadedPrimadb

Kind: function

export declare function createThreadedPrimadb(replicaId?: string | null, options?: ThreadedPrimadbInitOptions): Promise<Primadb>;

Re-exports

export * from "./vendor/threads/primadb.js";
export * from "./hooks.js";
export { initWasm as initWasmThreads };
export default bootstrapPrimadbThreads;

Thread pool bootstrap

The threaded build also re-exports the wasm thread-pool bootstrap helper when built with wasm-threads:

function initThreadPool(threads: number): Promise<void>;

Shared runtime classes such as Primadb, Chain, WebSocketSync, and WebRtcMesh are documented on the browser runtime API page.