Quick Start
Get your FlatWP site up and running in under 10 minutes!
Prerequisites
Before you begin, make sure you have:
- Node.js 20.0+ installed (Download)
- WordPress 6.4+ running with admin access
- Package manager: npm, yarn, or pnpm (we recommend pnpm)
- A code editor (VS Code recommended)
Check out WordPress.org for installation guides. Local development options include:
- Local by Flywheel - Easy local WordPress (recommended)
- MAMP - macOS/Windows local server
- XAMPP - Cross-platform solution
Step 1: Clone the Starter Template
Clone the FlatWP starter repository:
# Clone the repository
git clone https://github.com/flatwp/flatwp-starter.git my-site
cd my-site
Or use the GitHub "Use this template" button for a cleaner start without git history.
Step 2: Install Dependencies
Install the required packages:
# Using pnpm (recommended - faster)
pnpm install
# Or using npm
npm install
# Or using yarn
yarn install
pnpm is faster and uses less disk space than npm. Install it with: npm install -g pnpm
Step 3: Configure Environment Variables
You can configure your environment variables interactively or manually.
Option A: Interactive Setup (Recommended)
Run the interactive setup script:
pnpm run setup
This will guide you through setting up your .env.local file with all required variables.
Option B: Manual Setup
Create a .env.local file in the project root:
cp .env.example .env.local
Edit .env.local with your WordPress details:
# WordPress GraphQL endpoint
NEXT_PUBLIC_WORDPRESS_API_URL=https://your-wordpress.com/graphql
# Secret for revalidation webhooks
FLATWP_SECRET=your-secure-random-string
openssl rand -base64 32
Step 4: Set Up WordPress
Install Required Plugins
1. Install WPGraphQL
- Log in to your WordPress admin dashboard
- Go to Plugins → Add New
- Search for "WPGraphQL"
- Click Install Now, then Activate
2. Install FlatWP Companion Plugin
The FlatWP plugin connects WordPress to Next.js and provides on-demand revalidation:
- Download
flatwp-wordpress-connector.zipfrom GitHub Releases - Go to Plugins → Add New → Upload Plugin
- Choose the ZIP file and click Install Now
- Click Activate
Alternatively, use the download script included in the starter:
pnpm run download-plugin
This downloads the latest plugin version to your project folder.
Configure Plugin Settings
- In WordPress, go to FlatWP in the admin menu
- Navigate to the Settings tab
- Enter your configuration:
| Setting | Value |
|---|---|
| Next.js URL | http://localhost:3010 |
| Revalidation Secret | Your FLATWP_SECRET from .env.local |
| Preview Secret | Same as revalidation secret (optional) |
- Enable Webhooks toggle
- Click Save Settings
- Return to Dashboard tab and verify "Connected" status with green indicator
Step 5: Generate GraphQL Types
Generate TypeScript types from your WordPress GraphQL schema:
# Using pnpm
pnpm graphql:codegen
# Or using npm
npm run graphql:codegen
This creates type-safe interfaces in graphql/generated/.
Step 6: Start Development Server
Run the development server:
# Using pnpm
pnpm dev
# Or using npm
npm run dev
Open http://localhost:3010 in your browser. You should see your FlatWP site! 🎉
The development server runs on port 3010 by default. Change it in package.json if needed.
Step 7: Create Your First Page
Let's create a simple "About" page to see everything working:
In WordPress
- Go to Pages → Add New
- Title: "About Us"
- Add your content in the editor
- Click Publish
View Your Page
- Go to
http://localhost:3010in your browser - Your new "About Us" page should appear automatically
- Click on it to see your content! ✨
Success Checklist
Make sure everything is working:
- Next.js site loads at
http://localhost:3010 - WordPress pages appear in navigation
- FlatWP plugin shows green "Connected" status
- Making changes in WordPress updates the Next.js site
- No errors in browser console (F12)
If everything is checked, congratulations! Your FlatWP site is running! 🎉
Common Issues & Solutions
GraphQL Endpoint Not Found
Error: "Failed to fetch from WordPress GraphQL endpoint"
Solutions:
- Verify WPGraphQL plugin is activated in WordPress
- Check your
.env.localhas the correctNEXT_PUBLIC_WORDPRESS_API_URL - Test the endpoint in browser:
https://your-wordpress-site.com/graphql - Make sure WordPress site is accessible from your computer
CORS Errors
Error: "Access-Control-Allow-Origin blocked"
Solution: The FlatWP companion plugin handles CORS automatically. If you still see errors:
- Ensure the plugin is activated
- Check that your Next.js URL is correctly configured in plugin settings
- Clear your browser cache
GraphQL Types Not Generated
Error: "Cannot find module './graphql/generated'"
Solution:
# Make sure WordPress is running
# Then generate types
pnpm graphql:codegen
If it fails, check:
- WordPress site is accessible
- WPGraphQL plugin is activated
.env.localhas correct URL
FlatWP Plugin Shows "Disconnected"
Problem: Red status in WordPress FlatWP settings
Solutions:
- Make sure Next.js dev server is running (
pnpm dev) - Check secrets match between WordPress and
.env.local - Verify Next.js URL is correct in WordPress settings
Next Steps
Now that your FlatWP site is running, here's what to explore:
Immediate Next Steps
- Environment Variables - Configure your site
- WordPress Plugin Setup - Advanced plugin features
- Content Management - Learn to create and manage content
When You're Ready
- ISR & Caching - Understand rendering strategies
- Customization - Customize your site
- Deployment - Deploy your site
Quick Reference
Common Commands
# Development
pnpm dev # Start dev server (port 3010)
pnpm build # Build for production
pnpm start # Run production build locally
# Code Quality
pnpm lint # Check code quality
pnpm type-check # TypeScript validation
pnpm graphql:codegen # Update WordPress types
# Utilities
pnpm clean # Clear build cache
Project Structure
my-flatwp-site/
├── app/ # Next.js pages and routes
├── components/ # React components
├── lib/ # Utilities and helpers
├── graphql/ # GraphQL queries
├── public/ # Static files
└── .env.local # Your secrets (not in git)
Need Help?
Got stuck? Here's how to get help:
- Check this guide - Reread the troubleshooting section
- Search docs - Use the search bar at the top
- Ask the community - Post in GitHub Discussions
- Report bugs - Open an issue on GitHub
Happy building!