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.
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.
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.
import { MakeswiftApiHandler } from "@makeswift/runtime/next/server";import { strict } from "assert";import { runtime } from "@/makeswift/runtime";// make custom components' data available for introspectionimport "@/makeswift/components";strict( process.env.MAKESWIFT_SITE_API_KEY, "MAKESWIFT_SITE_API_KEY is required");const handler = MakeswiftApiHandler(process.env.MAKESWIFT_SITE_API_KEY, { runtime,});export { handler as GET, handler as POST, handler as OPTIONS };
import { MakeswiftApiHandler } from "@makeswift/runtime/next/server";import { strict } from "assert";import { runtime } from "@/makeswift/runtime";// make custom components' data available for introspectionimport "@/makeswift/components";strict( process.env.MAKESWIFT_SITE_API_KEY, "MAKESWIFT_SITE_API_KEY is required");export default MakeswiftApiHandler(process.env.MAKESWIFT_SITE_API_KEY, { runtime,});
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.