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.
Install this in any server-side Node.js / Deno / Bun project.
npm install modal
npm package: https://www.npmjs.com/package/modal
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.
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:
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
For usage questions and other support, please reach out on the Modal Community Slack.