modal-ts
v0.8.1
Published
Unofficial Modal SDK for JavaScript/TypeScript
Maintainers
Readme
modal-ts
Unofficial Modal SDK for TypeScript/JavaScript. Forked from modal-labs/libmodal (Apache-2.0).
Install
npm install modal-tsQuick Start
import { ModalClient } from "modal-ts";
const modal = new ModalClient();
// Call a deployed function
const echo = await modal.functions.fromName("my-app", "echo");
const result = await echo.remote(["Hello world!"]);
console.log(result);
// Run a sandbox
const app = await modal.apps.fromName("my-app", { createIfMissing: true });
const image = modal.images.fromRegistry("alpine:3.21");
const sb = await modal.sandboxes.create(app, image, { command: ["echo", "hi"] });
console.log(await sb.stdout.readText());
await sb.terminate();Authentication
Set environment variables or configure ~/.modal.toml:
export MODAL_TOKEN_ID=ak-...
export MODAL_TOKEN_SECRET=as-...Features
- Functions - Call deployed Modal functions and classes
- Sandboxes - Create and manage sandboxes with exec, stdin/stdout, tunnels, filesystem access
- Queues - Distributed FIFO queues with partition support
- Volumes - Persistent storage
- Images - Build container images from registries, Dockerfiles, ECR, GCP Artifact Registry
- Secrets - Manage environment secrets
- Deploy - Deploy apps, functions, and classes via gRPC API
Development
bun install # Install deps + generate proto
bun run typecheck # Type check
bun run lint # Biome lint
bun run format # Biome format
bun run build # Build (esbuild + tsc)
bun run test # Run tests (vitest)Differences from upstream
This fork diverges from modal-labs/libmodal:
- TypeScript-only - Go SDK removed
- No Python dependency - Test infrastructure and release scripts rewritten in TypeScript
- Bun - Uses Bun instead of npm
- Biome - Uses Biome instead of ESLint + Prettier
- Strict TypeScript -
verbatimModuleSyntax,noUncheckedIndexedAccess,exactOptionalPropertyTypesenabled. Noany, no@ts-directives - esbuild - Direct esbuild instead of tsup
License
Apache-2.0. Proto definitions from modal-labs/modal-client (Apache-2.0).
