Background Jobs
Background Jobs are server functions that can be configured to be triggered on website events to do background tasks without impeding the web flow of a user. In our templates, they are mainly used to send emails to users and update databases upon successful purchases or sign-ups. However, background jobs are very versatile and can be configured to serve a many number of functions.
Features
- Powered by Inngest: modern queuing and orchestration library.
- Email notifications upon successful checkouts, subscriptions, purchases and newsletter sign-ups.
- Asynchronously update databases without impeding user web flow.
- Easy to configure to your needs and brand.
What's Included
< SubscriptionSuccess />
Asynchronously updates the database and sends congratulatory email to users with successful subscription purchases. The email can easily be configured using the Email Templates.
< CheckoutSuccess />
Similar to SubscriptionSuccess
, asynchronously updates the database and sends congratulatory email to users with successful purchases.
< Welcome />
Asynchronously sends a welcome email to users for signing up to Newsletter.
Setup
Acquire environment variables from inngest.com by signing up and configure the variables as follows:
Configure inngest client located at /lib/inngest/client.ts
:
Customization
Creating Background Jobs
To create your own background jobs start by creating a file under src/jobs
.
event.data
is an object containing any value sent to the api endpoint.
Add this job function to the api in src/app/(routes)/api/inngest/route.ts
.
Customizing Email Templates
Customizing emails sent to your users asynchronously is so much easier with our Email Templates components. You can learn more about customizing email templates in its documentation page. Here we will just show how to send those email templates using background jobs.
This real example showcases how an email template can be used in conjecture with a background job. It uses the resend
library to send emails that contain React frontend.