Skip to Content
DocsReferenceClient Configuration

Client Configuration Options

Most of the client configuration is provided out-of-the-box from our Dashboard, and should not be changed in-hand. There are, however, a few additional configurations you can add to tweak the integration to your needs:

PropertyTypeDefaultDescription
batchWindowMsnumber25By default we batch requests in small windows to reduce unnecessary network overhead. If you have special needs, you can customize the window duration with this property. By providing a negative value (e.g. -1), you can disable request batching all together.

In supported browsers batching happens with half-duplex connections, meaning that requests will be streamed to our infrastructure for instant processing in spite of batching.
logLevelstringwarnConfigure the verbosity of outputs coming from the Direct Client, possible values are “debug”, “info”, “warn” and “error”.
preferJSONbooleanfalseBy default our client prefers communicating with Direct infrastructure using our custom-made Wire protocol. While the Wire format is heavily optimized and reduces bandwidth usage, the format is also not easily readable, and can make inspection and debugging difficult for developers.

By enabling this setting, you can opt-in to using a NDJSON based format instead for a more developer-friendly transmission of data.

Note that it is strongly discouraged to leave this setting on in production, as it negatively impacts the performance of your application as compared to using the Wire format.
devModebooleanfalsePuts the client into development mode, bypassing the Direct infrastructure for your end-users. When this setting is enabled, developers can opt into the full Direct integration by adding “?directdev=true” as a query parameter in the website URL.

Example

Below is a basic example of applying these configurations in your provider:

// Import dependencies import { createDirectViemClient } from "@direct.dev/viem"; // Initialize the Direct Client const client = createDirectViemClient({ projectId: "your-project-id", // From the Direct dashboard projectToken: "************", // From the Direct dashboard networkId: "your-network-id", // e.g. "ethereum", "polygon" providers: ["https://your-provider-endpoints.com/"], // Additional options are added here batchWindowMs: 50, logLevel: "info", preferJSON: true, }); // Example: Fetch the latest block number const blockNumber = await client.getBlockNumber();
Last updated on