Skip to main content

Compatability

Understand what environments the Tableland SDK supports.


The Tableland SDK has certain dependencies and requirements that you'll need to be aware of before you can use it in your project. This page provides a reference for what you can use and some workarounds, where applicable.

Synopsis

The @tableland/sdk can support the following environments or dependencies:

  • Node.js 18.x+.
  • Both ESM and CommonJS modules are supported.
  • ethers v6.x, specifically, [email protected].

Build systems

The Tableland SDK uses an optimized WASM build of our SQL parser under the hood. Unfortunately, some build systems such as Vite require an adjustment to their configuration to support this feature. To temporarily work around this issue, simply add @tableland/sqlparser to the excluded list under optimizeDeps in your vite.config.ts file:

vite.config.ts
// ...
optimizeDeps: {
exclude: ["@tableland/sqlparser"];
}
// ...

Node polyfills

The Tableland SDK makes use of the fetch API as well as Headers. If you're using a version of Node that came before the current LTS 18.x version. Any version prior to Node 18 might need to implement polyfills.

Installation

To use a polyfill, you'll first need to install node-fetch.

npm install node-fetch

Starting with node-fetch v3, it is an ESM-only module; you are not able to import it with require(). If you cannot switch to ESM and need CommonJS (CJS) support, you could use v2 (node-fetch@2)—or choose to use an async import().

Add the polyfill

In your source file, import fetch, Headers, Request, and Response from node-fetch. Then, you'll patch the global object in Node (globalThis), thus, enabling Tableland SDK compatability.

import fetch, { Headers, Request, Response } from "node-fetch";

if (!globalThis.fetch) {
globalThis.fetch = fetch;
globalThis.Headers = Headers;
globalThis.Request = Request;
globalThis.Response = Response;
}

Note that if you're using TypeScript, you can just declare globalThis as any in the ESM example declarations above (i.e., add a type to all of the references to globalThis).