Skip to content

Latest commit

 

History

History
97 lines (74 loc) · 5.26 KB

File metadata and controls

97 lines (74 loc) · 5.26 KB

Modal JavaScript SDK

JS Reference Documentation npm Version npm Downloads

The Modal JavaScript SDK provides convenient, on-demand access to serverless cloud compute on Modal from JS/TS projects. Use it to safely run arbitrary code in Modal Sandboxes, call Modal Functions, and interact with Modal resources.

It comes with built-in TypeScript type definitions.

We're approaching feature parity with the main Modal Python SDK, although defining Modal Functions will likely remain exclusive to Python.

Installation

Install this in any server-side Node.js / Deno / Bun project.

npm install modal

npm package: https://www.npmjs.com/package/modal

Requirements

Node 22 or later. We bundle both ES Modules and CommonJS formats, so you can load the package with either import or require() in any project.

Documentation

See the main Modal documentation and user guides for high-level overviews. For details, see the API reference documentation for for JS.

We also provide a number of examples:

Configuration

The config file path can be customized via MODAL_CONFIG_PATH (defaults to ~/.modal.toml).

Authenticating with Modal

You also need to authenticate with Modal (see Getting started). Either sign in with the Modal CLI using pip install modal && modal setup, or in machine environments set these environment variables:

# Replace these with your actual token!
export MODAL_TOKEN_ID=ak-NOTAREALTOKENSTRINGXYZ
export MODAL_TOKEN_SECRET=as-FAKESECRETSTRINGABCDEF

Telemetry and Observability

The Modal JavaScript SDK supports custom gRPC middleware for telemetry, tracing, and observability. You can add custom middleware to measure API call latency, trace requests, and integrate with observability tools like OpenTelemetry, DataDog, and others. See the telemetry example for more details.

Support

For usage questions and other support, please reach out on the Modal Community Slack.