Skip to content

Defer

Community

Overview

With Defer, keep your Serverless and Edge Functions fast by offloading long-running operations into Background Function, leverage the Bun Runtime for faster processing, and run Puppeteer scripts; all this without leaving your Next.js code and with the best Console available.

Production-ready in minutes

Simply create Background Functions inside your Next.js app and Git push.

Then, watch your background execution scale from the Defer Console.

Keep your Next.js app fast and scalable Offload slow code from your Edge Functions to Defer Background Functions with a few lines.

Leverage the Bun Runtime on Defer for compute-intensive Vercel Functions.

Additional Information

Getting started with Defer is achieved in under a few minutes, as covered in our Next.js Getting Started guide.

Sending an email using a Background Function is as simple as that:

// src/defer/sendMonthlyUsage.tsx
import { Resend } from "resend";
import MonthlyUsageEmail from "@/emails/MonthlyUsage";
const resend = new Resend(process.env.RESEND_API_KEY!);
async function sendMonthlyUsage(userId: string) {
// ...
await resend.emails.send({
from: "usage@defer.run",
to: "charly@defer.run",
subject: title,
html: title,
react: MonthlyUsageEmail({ /* ... */ }),
});
}
export default defer(sendMonthlyUsage, {
concurrency: 10,
retry: 5,
});

Once a Defer application is created, installing the Vercel Integration will automatically:

  • set your DEFER_TOKEN on the linked applications
  • List your Vercel Preview Environments within the Defer Console for a quicker setup.
Get started with Vercel and Defer.