LlamaIndex.TS is designed to work seamlessly across all major JavaScript runtimes. This is achieved through runtime-specific entry points and theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/run-llama/LlamaIndexTS/llms.txt
Use this file to discover all available pages before exploring further.
@llamaindex/env abstraction layer.
Supported Runtimes
Node.js
Full-featured support with filesystem access
Deno
Native ESM with secure permissions
Bun
Fast runtime with Node.js compatibility
Cloudflare Workers
Edge runtime with Workers API
Vercel Edge
Vercel Edge Runtime for serverless
Browser
Limited support for client-side use cases
Runtime-Specific Entry Points
Thellamaindex package provides different entry points that are automatically selected based on your runtime:
package.json conditional exports
The correct entry point is automatically selected by your bundler or runtime based on export conditions.
Entry Point Mapping
| Runtime | Export Condition | Entry Point File |
|---|---|---|
| Node.js ESM | import | src/index.ts |
| Node.js CJS | require | src/index.ts (compiled to CJS) |
| Cloudflare Workers | workerd | src/index.workerd.ts |
| Vercel Edge | edge-light | src/index.edge.ts |
| React Server Components | react-server | src/index.react-server.ts |
| Deno/Bun | import | src/index.ts |
Environment Abstraction Layer
The@llamaindex/env package provides a unified API across all runtimes:
@llamaindex/env exports
@llamaindex/env handles all runtime differences internally, so you can write runtime-agnostic code.Runtime-Specific Examples
Node.js
- Full Features
- Runtime Check
Node.js provides the complete LlamaIndex.TS feature set:
Node.js with filesystem
Cloudflare Workers
- Worker Implementation
- wrangler.toml
src/index.ts
Vercel Edge Runtime
- Next.js Route Handler
- Runtime Detection
- next.config.mjs
app/api/chat/route.ts
Deno
Deno with import maps
Bun
Bun runtime
Runtime Capabilities
| Feature | Node.js | Deno | Bun | CF Workers | Vercel Edge | Browser |
|---|---|---|---|---|---|---|
| File System | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ |
| Vector Indices | ✅ | ✅ | ✅ | ✅ | ✅ | ⚠️ |
| LLM Chat | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Streaming | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Embeddings | ✅ | ✅ | ✅ | ✅ | ✅ | ⚠️ |
| Agents | ✅ | ✅ | ✅ | ✅ | ✅ | ⚠️ |
| Async Local Storage | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| Local Models | ✅ | ✅ | ✅ | ❌ | ❌ | ⚠️ |
⚠️ = Limited support or requires specific configuration
Environment Variables
Node.js / Deno / Bun
.env
Load with dotenv
Cloudflare Workers
Use setEnvs helper
Vercel Edge Runtime
Edge Runtime env
Runtime Limitations
Cloudflare Workers
Cloudflare Workers
Limitations:
- No file system access (use KV, R2, or D1 for storage)
- No native Node.js modules
- 1MB script size limit (use dynamic imports)
- CPU time limits per request
- Use
vectorStoreswith external services (Pinecone, Qdrant) - Dynamic imports to reduce initial bundle size
- Stream responses for long-running operations
Vercel Edge Runtime
Vercel Edge Runtime
Limitations:
- No file system access
- Limited Node.js API compatibility
- 1MB middleware size limit
- Cold start considerations
- Use
withLlamaIndexNext.js plugin - Leverage Vercel KV or external vector stores
- Keep dependencies minimal
Browser
Browser
Limitations:
- No file system access
- CORS restrictions for API calls
- Bundle size concerns
- No native crypto APIs in older browsers
- Client-side chat interfaces
- Browser-based document processing with FileReader API
- WebAssembly embeddings (limited)
AsyncLocalStorage
LlamaIndex.TS uses AsyncLocalStorage for context-aware Settings:Settings context isolation
AsyncLocalStorage is polyfilled for runtimes that don’t have native support.
Best Practices
Use Dynamic Imports
In edge runtimes, use dynamic imports to reduce bundle size:
Test Multiple Runtimes
Validate your code works across target runtimes in CI/CD
Handle Missing APIs
Check for API availability before using runtime-specific features
Optimize Bundle Size
Use sub-module imports and tree-shaking for edge deployments
Next Steps
Settings Configuration
Learn how to configure global settings for your runtime
Data Flow
Understand how data flows through the framework