DEV Community

Alex Spinov
Alex Spinov

Posted on

Inngest Has a Free Event-Driven API That Replaces Queues and Crons

Inngest lets you build event-driven workflows with zero infrastructure. Send an event, Inngest runs your functions — with retries, delays, and step-by-step execution.

Define Functions

import { inngest } from './client';

export const sendWelcomeSequence = inngest.createFunction(
  { id: 'welcome-sequence' },
  { event: 'user/signup' },
  async ({ event, step }) => {
    // Step 1: Send welcome email (immediately)
    await step.run('send-welcome', async () => {
      await sendEmail(event.data.email, 'Welcome!');
    });

    // Step 2: Wait 1 day
    await step.sleep('wait-1-day', '1d');

    // Step 3: Send tips email
    await step.run('send-tips', async () => {
      await sendEmail(event.data.email, 'Getting Started Tips');
    });

    // Step 4: Wait 3 days
    await step.sleep('wait-3-days', '3d');

    // Step 5: Ask for feedback
    await step.run('send-feedback-request', async () => {
      await sendEmail(event.data.email, 'How are you liking it?');
    });
  }
);
Enter fullscreen mode Exit fullscreen mode

Send Events

import { Inngest } from 'inngest';

const inngest = new Inngest({ id: 'my-app' });

// From anywhere in your app
await inngest.send({
  name: 'user/signup',
  data: { userId: '123', email: 'alice@example.com', plan: 'pro' }
});
Enter fullscreen mode Exit fullscreen mode

Fan-Out Pattern

export const processOrder = inngest.createFunction(
  { id: 'process-order' },
  { event: 'order/created' },
  async ({ event, step }) => {
    // Run multiple steps in parallel
    const [inventory, payment] = await Promise.all([
      step.run('check-inventory', () => checkInventory(event.data.items)),
      step.run('process-payment', () => chargeCard(event.data.paymentMethod))
    ]);

    // Sequential step after parallel ones
    await step.run('ship-order', () =>
      createShipment(event.data.items, event.data.address)
    );
  }
);
Enter fullscreen mode Exit fullscreen mode

Scheduled Functions (Cron)

export const dailyCleanup = inngest.createFunction(
  { id: 'daily-cleanup' },
  { cron: '0 2 * * *' }, // 2 AM daily
  async ({ step }) => {
    await step.run('clean-temp-files', () => cleanTempFiles());
    await step.run('archive-old-data', () => archiveOldRecords());
  }
);
Enter fullscreen mode Exit fullscreen mode

Why This Matters

  • No queues to manage: No Redis, RabbitMQ, or SQS setup
  • Step functions: Each step retries independently
  • Event-driven: Decouple services with events
  • Local dev: Full local development server included

Need custom event-driven systems or workflow automation? I build developer tools. Check out my web scraping actors on Apify or reach out at spinov001@gmail.com for custom solutions.

Top comments (0)