Create a Project
Scaffold a React application with Puzzle UI, Theme, optional Tailwind CSS, and optional Puzzle Auth.
The @puzzle-ui/create package creates a new React application with Puzzle UI installed and configured.
It supports Next.js, TanStack Start, and a basic React + Vite application.
Requirements
- Node.js 20.19 or later.
- npm, Bun, pnpm, or Yarn.
- An internet connection to download framework templates and dependencies.
Run the generator
npm
npx @puzzle-ui/createBun
bunx @puzzle-ui/createpnpm
pnpm dlx @puzzle-ui/createYarn
yarn dlx @puzzle-ui/createYarn's dlx command requires Yarn 2 or later. With Yarn Classic, use the npm command.
Interactive setup
The generator asks for four options.
Project name
Enter a project name. The generator converts it to kebab-case and uses it for the target directory and package name.
Framework
| Framework | Generated application |
|---|---|
| Next.js | Next.js App Router with TypeScript |
| TanStack Start | Full-stack React application |
| Basic React | React, Vite, and TypeScript |
Next.js and TanStack Start projects are generated using their official CLI tools. The Basic React template is generated directly by Puzzle.
Tailwind CSS
You can optionally configure Tailwind CSS v4.
When enabled, the generator configures the appropriate integration for the selected framework and installs the required development dependencies.
Puzzle Auth
You can optionally add Puzzle authentication.
When enabled, the generator installs:
-
@puzzle-ui/auth -
@puzzle-ui/fullstack -
@puzzle-ui/session
For Next.js and TanStack Start, it also creates:
- An application-level
AuthProvider. - A sign-in page.
- A sign-up page.
- A framework-specific authentication API route.
- A server-only AuthServer registration module.
- An application bootstrap function.
For Basic React, it creates the AuthProvider and sign-in/sign-up components. A Basic React application has no server runtime, so its authentication API must be hosted separately.
Complete server configuration is required
Puzzle Auth requires application-specific security dependencies. The generator does not create an insecure password hasher, fake storage adapter, or process-local production rate limiter. The generated API route returns HTTP 503 until you register a real AuthServer.
See Authentication Setup for the required server configuration.
What gets configured
After framework generation, the CLI:
- Configures framework package transpilation.
- Adds the Puzzle theme provider.
- Creates a starter page using the Puzzle UI package.
- Sets the generated package name.
- Optionally configures and installs Tailwind CSS.
- Optionally creates the Puzzle Auth client and server integration files.
- Installs the selected Puzzle packages.
The target directory must not already exist. The generator never overwrites an existing project.
Start developing
Move into the generated directory and run its development server.
cd my-dashboard
npm run devUse the package manager selected during setup. For example:
cd my-dashboard
bun run devManual installation
Install the UI and theme packages:
npm install @puzzle-ui/ui @puzzle-ui/themeAdd the theme provider at the root of your application.
import { Theme } from "@puzzle-ui/theme";
import { Button } from "@puzzle-ui/ui";
const App = () => (
<Theme theme="system">
<main>
<h1>My application</h1>
<Button>Continue</Button>
</main>
</Theme>
);
export default App;To add the authentication packages:
npm install @puzzle-ui/auth @puzzle-ui/fullstack @puzzle-ui/sessionFollow Authentication Setup before exposing authentication routes.
Troubleshooting
The project directory already exists
Choose a different project name or remove the existing directory yourself. The generator deliberately refuses to overwrite existing files.
Framework generation fails
The generator downloads the framework CLI through your selected package manager. Verify that the package manager is installed and can access the package registry.
Dependency installation fails
Run the failed installation command manually from the generated project directory. Check the package manager output for registry, network, or version errors.
Authentication returns HTTP 503
The server bootstrap is intentionally incomplete. Configure the storage adapter, password hasher, rate limiter, session manager, MFA manager, step-up manager, cookies, CSRF policy, and trusted client IP resolver.
Register the resulting AuthServer with configureAuthServer.
Tailwind styles are missing
Check that Tailwind was enabled during setup and that the generated CSS entry point is imported by the application.
Package details
The generator is published as @puzzle-ui/create. Its executable is named create-puzzle.
The package requires Node.js 20.19 or later.