Arguments

  1. apiKey
    string
    required

    The API key for the Makeswift site.

  2. options
    object

    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.