+
Skip to content
@MotiaDev

Motia

A Modern Unified Backend Framework

Motia logo Motia logo (dark)

🔥 A Modern Unified Backend Framework for APIs, Events, and Agents 🔥

Website Documentation npm License

GitHub Stars Discord Twitter Follow


🎯 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.

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 emits an event, and an Event Step that processes it.

TypeScript
// steps/send-message.step.ts
export const config = {
  name: 'SendMessage',
  type: 'api',
  path: '/messages',
  method: 'POST',
  emits: ['message.sent']
};

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

export const handler = async (input, { logger }) => {
  logger.info('Processing message', input);
};
Python
# send_message_step.py
config = {
    "name": "SendMessage",
    "type": "api",
    "path": "/messages",
    "method": "POST",
    "emits": ["message.sent"]
}

async def handler(req, context):
    await context.emit({
        "topic": "message.sent",
        "data": {"text": req.body["text"]}
    })
    return {"status": 200, "body": {"ok": True}}
# process_message_step.py
config = {
    "name": "ProcessMessage",
    "type": "event",
    "subscribes": ["message.sent"]
}

async def handler(input, context):
    context.logger.info("Processing message", input)
JavaScript
// steps/send-message.step.js
const config = {
  name: 'SendMessage',
  type: 'api',
  path: '/messages',
  method: 'POST',
  emits: ['message.sent']
};

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

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

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

module.exports = { config, handler };

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

Learn more about Steps →

Read our documentation and get started today: npx motia@latest create

GitHub commit activity GitHub issues GitHub pull requests

Join thousands of developers building the future of backend development

🤝 Contributing

We love contributions! Check out our Contributing Guide to get started.

Contributors

📄 License

Motia is MIT licensed and open source. Build amazing things! 🚀


WebsiteDocumentationDiscordTwitter

Made with ❤️ by the Motia team and community

Pinned Loading

  1. motia motia Public

    Multi-Language Backend Framework that unifies APIs, background jobs, workflows, and AI Agents into a single core primitive with built-in observability and state management.

    TypeScript 9.4k 720

  2. motia-examples motia-examples Public

    A community maintained list of flow examples built with Motia

    280 82

  3. chessarena-ai chessarena-ai Public

    TypeScript 35 8

Repositories

Showing 10 of 16 repositories

People

This organization has no public members. You must be a member to see who’s a part of this organization.

Most used topics

Loading…

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载