On this page

core.createstaticclient

Home > @medplum/core > createStaticClient

createStaticClient() function​

Creates a MedplumClient that serves reads from the given resources and never touches the network.

Use it to render Medplum React components from data gathered up front:

const medplum = createStaticClient([report, patient, ...observations]);
<MedplumProvider medplum={medplum}>
  <DiagnosticReportDisplay value={report} />
</MedplumProvider>

Only reads by type and id (GET [base]/Type/id) are supported. A read of a resource not in the list fails with "Not found", the same as a real server. Any other request, such as a search or a write, fails with "Bad request".

Signature:

export declare function createStaticClient(resources: Resource[], options?: MedplumClientOptions): MedplumClient;

Parameters​

Parameter

Type

Description

resources

Resource[]

The resources to serve.

options

MedplumClientOptions

(Optional) Optional client options. fetch, storage, and autoBatchTime are always replaced.

Returns:

MedplumClient

The client.