MakeswiftApiHandler
An API route for Makeswift that adds support for preview mode, on-demand revalidation, and other features that make Makeswift work seamlessly with your Next.js app.
Arguments
The API key for the Makeswift site.
Options for site version and locale.
Untitled
An instance of ReactRuntime
This function is called when the builder requests the list of fonts available for the site. The function should return an array of FontFamily objects.
The src field is used to preview the font in the builder. The src field can be either a relative or absolute URL. If the src field is omitted, the font is still selectable but uses a fallback font in the builder.
An object containing event handlers for the Makeswift site.
Available events
If defined, this function is called when the site is published.
Error handling
Any errors thrown in the event handler will be logged and ignored.
Local development
Since onPublish is powered by Makeswift webhooks, it’s not possible to test them locally (e.g., localhost:3000) at this time. We have plans to enable this via tunneling by leveraging the Makeswift CLI but don’t have that ready just yet.
Examples
App Router
Pages router
Adding fonts
The following example adds Spline Sans and Spline Sans Mono Google Fonts to the site using next/font and adds them to the MakeswiftApiHandler.
For more information on adding fonts to your Next.js app, see our Adding Fonts guide.
We recommend using variable fonts as they reduce the number of font files requested.