Reference
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
-
apiKeystringrequired
The API key for the Makeswift site.
-
optionsobject
Options for site version and locale.
Examples
App router
app/api/makeswift/[...makeswift]/route.ts
import { MakeswiftApiHandler } from "@makeswift/runtime/next/server"
import { strict } from "assert"
import { runtime } from "@/makeswift/runtime"
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 }
Pages router
pages/api/makeswift/[...makeswift].ts
import { MakeswiftApiHandler } from "@makeswift/runtime/next/server"
import { strict } from "assert"
import { runtime } from "@/makeswift/runtime"
strict(process.env.MAKESWIFT_SITE_API_KEY, "MAKESWIFT_SITE_API_KEY is required")
export default MakeswiftApiHandler(process.env.MAKESWIFT_SITE_API_KEY, {
runtime,
})
Adding fonts
The following example adds Spline Sans and Spline Sans Mono fonts to the site using next/font
and adds them to the MakeswiftApiHandler
. Using a variable font reduces the number of font files requested.
Was this page helpful?