Back to Iii

README

frameworks/motia/motia-js/README.md

0.13.012.3 KB
Original Source
<a href="https://motia.dev"> </a> <p align="center"> <a href="https://trendshift.io/repositories/14032" style="margin-right:8px;"> </a> <a href="https://vercel.com/blog/summer-2025-oss-program#motia" target="_blank" style="margin-left:8px;"> </a> </p> <p align="center"> <strong>πŸ”₯ The Unified Backend Framework That Eliminates Runtime Fragmentation πŸ”₯</strong> </p> <p align="center"> <em>APIs, background jobs, queueing, streaming, states, workflows, AI agents, observability, scaling, and deployment all in one system. JavaScript, TypeScript, Python, and more in a single core primitive</em> </p> <p align="center"> <a href="https://www.npmjs.com/package/motia"> </a> <a href="https://github.com/MotiaDev/motia/blob/main/LICENSE"> </a> <a href="https://github.com/MotiaDev/motia"> </a> <a href="https://twitter.com/motiadev" target="_blank"> </a> <a href="https://discord.gg/motia" target="_blank"> </a> </p> <p align="center"> <a href="https://www.motia.dev/manifesto">πŸ’‘ Motia Manifesto</a> β€’ <a href="https://www.motia.dev/docs/getting-started/quick-start">πŸš€ Quick Start</a> β€’ <a href="https://www.motia.dev/docs/concepts/steps">πŸ“‹ Defining Steps</a> β€’ <a href="https://www.motia.dev/docs">πŸ“š Docs</a> </p>

πŸš€ Create your first Motia App

Get started in seconds:

bash
npx motia@latest create

🎯 What is Motia?

Backend development today is fragmented.

APIs live in one framework, background jobs in another, queues and schedulers elsewhere, and now AI agents and streaming systems have their own runtimes. Add observability and state management on top, and you're stitching together half a dozen tools before writing your first feature.

Motia unifies all of these concerns around one core primitive: the Step.

Just as React made frontend development simple by introducing components, Motia redefines backend development with Steps - a single primitive that handles everything.

Every backend pattern, API endpoints, background jobs, queues, workflows, AI agents, streaming, observability, and state, is expressed with the same primitive.

To read more about this, check out our manifesto.


The Core Primitive: the Step

A Step is just a file with a config and a handler. Motia auto-discovers these files and connects them automatically.

Here's a simple example of two Steps working together: an API Step that enqueues an event, and an Event Step that processes it.

<details open> <summary><b>TypeScript</b></summary>
ts
// steps/send-message.step.ts
export const config = {
  name: 'SendMessage',
  triggers: [
    {
      type: 'http',
      method: 'POST',
      path: '/messages',
    }
  ],
  enqueues: ['message.sent']
};

export const handler = async (req, { enqueue }) => {
  await enqueue({
    topic: 'message.sent',
    data: { text: req.body.text }
  });
  return { status: 200, body: { ok: true } };
};
ts
// steps/process-message.step.ts
export const config = {
  name: 'ProcessMessage',
  triggers: [
    {
      type: 'queue',
      topic: 'message.sent',
    }
  ],
};

export const handler = async (input, { logger }) => {
  logger.info('Processing message', input);
};
</details> <details> <summary><b>JavaScript</b></summary>
js
// steps/send-message.step.js
const config = {
  name: 'SendMessage',
  triggers: [
    {
      type: 'http',
      method: 'POST',
      path: '/messages',
    }
  ],
  enqueues: ['message.sent']
};

const handler = async (req, { enqueue }) => {
  await enqueue({
    topic: 'message.sent',
    data: { text: req.body.text }
  });
  return { status: 200, body: { ok: true } };
};

module.exports = { config, handler };
js
// steps/process-message.step.js
const config = {
  name: 'ProcessMessage',
  triggers: [
    {
      type: 'queue',
      topic: 'message.sent',
    }
  ],
};

const handler = async (input, { logger }) => {
  logger.info('Processing message', input);
};

module.exports = { config, handler };
</details>

πŸ‘‰ With just two files, you've built an API endpoint, a queue, and a worker. No extra frameworks required.

Learn more about Steps β†’

πŸ’» Remix your own Motia App in Replit

πŸš€ Quickstart

Get Motia project up and running in under 60 seconds:

1. Bootstrap a New Motia Project

bash
npx motia@latest create   # runs the interactive terminal

Follow the prompts to pick a template, project name, and language.

2. Start the Workbench

Inside your new project folder, launch the dev server:

bash
npm run dev # ➜ http://localhost:3000

That's it! You have:

  • βœ… REST APIs with validation
  • βœ… Visual debugger & tracing
  • βœ… Multi-language support
  • βœ… Event-driven architecture
  • βœ… Zero configuration
  • βœ… AI development guides included (Cursor, OpenCode, Codex, and more)

πŸ“– Full tutorial in our docs β†’

πŸ€– AI-Assisted Development

Every Motia project includes detailed AI development guides that work with any AI coding tool:

The guides include patterns for API endpoints, background tasks, state management, real-time streaming, and complete architecture blueprints.

πŸ€– Learn more about AI development support β†’

🎯 Triggers

TypeWhen it runsUse Case
httpHTTP RequestREST endpoints
queueQueue subscriptionBackground processing
cronScheduleRecurring jobs
stateState changeState management
streamStream subscriptionReal-time streaming

πŸ“– Learn more about Steps β†’


🎯 Examples

A complete chess platform benchmarking LLM performance with real-time evaluation.

Live Website β†’ | Source Code β†’

Built from scratch to production deployment, featuring:

  • πŸ” Authentication & user management
  • πŸ€– Multi-agent LLM evaluation (OpenAI, Claude, Gemini, Grok)
  • 🐍 Python engine integration (Stockfish chess evaluation)
  • πŸ“Š Real-time streaming with live move updates and scoring
  • 🎨 Modern React UI with interactive chess boards
  • πŸ”„ Event-driven workflows connecting TypeScript APIs to Python processors
  • πŸ“ˆ Live leaderboards with move-by-move quality scoring
  • πŸš€ Production deployment on Motia Cloud

πŸ“š More Examples

View all 20+ examples β†’

ExampleDescription
AI Research AgentWeb research with iterative analysis
Streaming ChatbotReal-time AI responses
Gmail AutomationSmart email processing
GitHub PR ManagerAutomated PR workflows
Finance AgentReal-time market analysis

Features demonstrated: Multi-language workflows β€’ Real-time streaming β€’ AI integration β€’ Production deployment


🌐 Language Support

LanguageStatus
JavaScriptβœ… Stable
TypeScriptβœ… Stable
Pythonβœ… Stable
Ruby🚧 Beta
GoπŸ”„ Soon

πŸ“š Resources

🚧 Roadmap

We have a public roadmap for Motia, you can view it here.

Feel free to add comments to the issues, or create a new issue if you have a feature request.

FeatureStatusLinkDescription
Streams: RBACβœ… Shipped#495Add support for RBAC
Streams: Workbench UIβœ… Shipped#497Add support for Workbench UI
Queue Strategiesβœ… Shipped#476Add support for Queue Strategies
Reactive Stepsβœ… Shipped#477Add support for Reactive Steps
Point in time triggersπŸ“… Planned#480Add support for Point in time triggers
Workbench pluginsβœ… Shipped#481Add support for Workbench plugins
Rewrite core in Rustβœ… Shipped#482Rewrite our Core in Rust
Decrease deployment timeβœ… Shipped#483Decrease deployment time
Built-in database supportπŸ“… Planned#484Add support for built-in database

🀝 Contributing

We welcome contributions! Check our Contributing Guide to get started.


<div align="center">

πŸš€ Get Started β€’ πŸ“– Docs β€’ πŸ’¬ Discord

<a href="https://git-history.com"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://git-history.com/api/embed/stars?repos=MotiaDev/motia&theme=dark" /> <source media="(prefers-color-scheme: light)" srcset="https://git-history.com/api/embed/stars?repos=MotiaDev/motia&theme=light" /> </picture> </a>

<sub>⭐ Star us if you find Motia useful!</sub>

</div>