React + Next.js Setup
Step-by-step guide to integrate Frontfriend with React and Next.js
Frontfriend Integration Guide for React + Next.js
This guide will walk you through integrating Frontfriend with your React or Next.js project.
Prerequisites
- React project (Next.js, Vite, or Create React App)
- Node.js >= 16
- Tailwind CSS installed (or will be installed)
Installation
Step 1: Install Dependencies
Step 2: Create Configuration
Create frontfriend.config.js in your project root:
Step 3: Configure Tailwind
Update tailwind.config.js:
Step 4: Import Tailwind CSS
For Next.js, in app/globals.css or styles/globals.css:
Step 5: Configure Next.js
For Next.js projects, you need to wrap your config with frontfriend:
Update next.config.js:
The frontfriend wrapper ensures proper integration with Frontfriend's build process and hot reloading.
For TypeScript projects, also update tsconfig.json or jsconfig.json:
Step 6: Initialize Design Tokens
This creates a local cache of your design system tokens.
Step 7: Download React Components
Components will be downloaded to src/components/ui/ (as configured in your aliases).
Using Design Tokens
After initialization, use your design tokens as Tailwind utilities:
Using Components
CLI Commands
npx frontfriend init- Initialize/update design tokensnpx frontfriend init --force- Force refresh tokensnpx frontfriend status- Check configuration statusnpx frontfriend download <components> -f react- Download componentsnpx frontfriend clean- Clear token cache
Troubleshooting
Styles not applying
- Check that
npx frontfriend initcompleted successfully - Verify cache exists:
npx frontfriend status - Force refresh:
npx frontfriend init --force - Restart your development server
Components in wrong location
- Check your
frontfriend.config.jshas correctuialias - Use
-oflag to override:npx frontfriend download button -f react -o ./components
ff-id not found
- Ensure
frontfriend.config.jsexists in project root - Verify the
ff-idfield is present and correct
TypeScript errors
- Ensure your tsconfig.json has the correct path aliases
- Restart your TypeScript server in your IDE