Skip to content
Browse docs and components

Integrations

Next.js

Setting up Forme in a Next.js App Router project, including the React Server Components boundary.

2 min read · 4 sections

Forme works in any React project with Tailwind v4. Next.js is the smoothest case, because the copy-based model suits the App Router exactly: the code you installed is code your bundler already understands.

Setup#

bash
npx create-next-app@latest my-app --typescript --tailwind
cd my-app
npx shadcn@latest init
npx shadcn@latest add @forme/button

Then import the tokens in src/app/globals.css, after Tailwind:

css
@import "tailwindcss";
@import "./components/forme/foundation.css";

Or use `npx @formeui/cli init` or `npx @formeui/cli add` and skip that step. Both write the line for you, into the right file with the right relative path, and neither will touch a stylesheet that already imports it.

Nothing else is Next.js-specific setup. There is nothing to add to next.config, no transpile list and no external package declaration, because there is no package to transpile.

Why the import matters#

Without it, nothing errors. Your buttons render with no padding, no radius and no colour — just text in a box. That is what a CSS custom property being undefined looks like: the utility class exists, resolves, and has nothing to point at. It is the single most confusing thing that can happen to a first Forme install, which is why the CLI does it rather than leaving it to remember.

Server and client components#

Forme components are server components unless they genuinely need state. That means you can render a whole form from a server component and add "use client" only to the leaf that has an event handler.

When you do need interactivity, put the client boundary at the smallest sensible place. This is the common mistake:

tsx
// Avoid: the whole shell becomes client-side JavaScript.
"use client";
export function CheckoutPage() {
  /* ... */
}
tsx
// Better: the page stays a server component.
export default function CheckoutPage() {
  return (
    <Shell>
      <OrderSummary />
      <PayButton />   {/* "use client" */}
    </Shell>
  );
}

Fonts#

Forme does not ship or require a webfont, and its components only ever ask for your --font-sans and --font-mono. If you use next/font, set those two variables on html and everything else follows.