-
Notifications
You must be signed in to change notification settings - Fork 1
Adding Interval to an existing Next.js app
Here's a short guide to using Interval in a Next.js project.
If you prefer to work by example, check out our Next.js starter sample project instead. Otherwise, read on!
There are two primary approaches to integrating Interval into an existing Next.js app.
We recommend running your internal tools in a separate process from your user-facing app. This prevents any bugs in your internal tools from impacting your user-facing app. And as a result, this should give you confidence to ship updates to your internal tools on a quicker cadence.
This is what we do ourselves. Even though our codebase is in a single repo, we run our own internal tools using a separate web worker on Render.
Follow these steps to add Interval to your Next.js app as a separate process.
Interval can be run in the same process as your Next.js app if you're using a custom server custom server. To accomplish this, just import Interval, call interval.listen()
and use like any other module in your project.
A custom server is required for this approach, since serverless environments like Vercel don't support our persistent listener model.
Even if you have a custom server, we don't recommend this approach. Running your internal tools in the same process as your user-facing app means that bugs in your internal tools may impact that app.
If you want to take this approach, you can simply follow the instructions in the Interval dashboard for adding Interval to an existing codebase. When following this approach, you'll want to import Interval into your Next.js custom server entry point file.