nook
Browse the docs

Blocks

A block is a whole section or page, such as a sign in card, an app shell or a pricing section, built only from Nook components. Like components, blocks are copied into your project, so you own the code and can change anything.

Browse them in the block library.

Install a block

nook add login-simple

The block is written to components/blocks/login-simple.tsx, together with the components it uses. Import it where you need it:

import { LoginSimple } from "@/components/blocks/login-simple";

export default function Page() {
  return <LoginSimple onSubmit={signIn} />;
}

What a block does and does not do

Blocks draw the screen and check the fields. They never talk to a server. You pass what should happen as props: onSubmit, onSave, onInvite and so on. A block may return a promise; its button shows the loader until the promise settles.

<LoginSimple
  loading={pending}
  error={state.error}
  onSubmit={async ({ email, password }) => {
    await signIn(email, password);
  }}
/>

Text, links and data are props too, so the same block works for your product: productName, forgotHref, members, plans.

Fit the frame

Blocks measure the space they are given, not the screen. Page level blocks, such as the app shell or the inbox, fill their parent: give the parent a height.

<div className="h-dvh">
  <AppShell>{children}</AppShell>
</div>

Use the error blocks in Next.js

error-404 and error-500 are made to be your not-found and error pages:

// app/not-found.tsx
import { Error404 } from "@/components/blocks/error-404";
export default function NotFound() {
  return <Error404 />;
}
// app/error.tsx
"use client";
import { Error500 } from "@/components/blocks/error-500";
export default function Error({ error, reset }: { error: Error & { digest?: string }; reset: () => void }) {
  return <Error500 onRetry={reset} reference={error.digest} />;
}

Styles and themes

Blocks use the same tokens and style variables as components, so they follow your theme and look right in Sharp, Soft and Bold, in light and dark.

Make it yours

Edit the file. A block is ordinary React: change the copy, remove a section, swap a component. If you want to remove a part, delete it; nothing else depends on it.