Next.jsWordPressReactStarter

wordpress-template — Next.js Starter Template

By AndrewUru

A WordPress headless frontend template built on Next.js App Router that reads content via REST API, optionally connects to WooCommerce REST API, and includes blog, page, shop, and on-demand ISR revalidation routes.

Explore the design

Compare the page layouts and mobile experience. Open any screenshot for a closer look.

3 previews
Desktop homepage1 / 3
Desktop captureTop of page

Actual screenshot captured by the server browser.

All pages & views 3

Screenshots show visual appearance; interactive behavior may differ.

Recorded 2026-10-14View source

What stands out

A quick read of the recorded project description.

01

Next.js App Router + TypeScript frontend that reads content through the WordPress REST API

02

Optional WooCommerce REST API integration; /shop shows a setup notice when keys are not configured

03

Built-in /api/revalidate on-demand ISR that supports revalidation triggered by tag or path

04

Reads /wp-json/wp/v2/types to automatically detect public CPTs and provides query helper functions

05

Preserves ACF fields in the REST response and includes a hero mapping and rendering example

06

Provides an npm run setup environment variable configuration wizard and a .env.example reference

Template Details

This is a Next.js template for building a WordPress headless frontend. The frontend uses App Router and TypeScript, fetches content through the WordPress REST API, and can optionally read product data through the WooCommerce REST API. The README states its tech stack is Next.js App Router, TypeScript, ESLint, and minimal CSS (no UI framework), and provides scripts including npm run setup installation wizard, npm run dev, npm run lint, and npm run typecheck.

The template's built-in routes include the homepage (latest posts, with featured products when Woo is enabled), /blog, /blog/[slug], /page/[slug], /shop, /product/[slug], and /api/revalidate. For CPTs, the application reads /wp-json/wp/v2/types and filters publicly viewable types, providing getTypes(), getEntries(typeSlug), and getEntryBySlug(typeSlug, slug) helper methods, but by default it does not generate dynamic routes for all CPTs; you need to add them yourself following the example. ACF fields are preserved if they appear in the REST response; the template includes a hero mapping example, and /page/[slug] automatically renders when fields such as hero_title are present. The template itself does not require the ACF plugin to be installed, and missing acf fields will not cause errors.

The revalidation endpoint /api/revalidate supports triggering via the x-revalidate-secret request header, the secret query parameter, or tag/path in the JSON body. Supported tags include wp:posts, wp:pages, wp:types, wp:cpt:<type>, woo:products, and woo:categories; if WP_REVALIDATE_SECRET is not set, the endpoint returns 404. The README does not provide a default approach for WordPress menu navigation, explaining that a custom endpoint or plugin is needed and a client must be added manually. For deployment, it only gives Vercel steps for importing, configuring environment variables, and redeploying.

Next.jsWordPressStarter

Is it right for your project?

Use Cases

  • Build a standalone frontend for an existing WordPress site with Next.js
  • Add WooCommerce product display on top of WordPress content
  • Trigger page and data cache revalidation via webhook or manual request
  • Read and render ACF custom fields (such as hero blocks) in pages

Suitable For

  • Developers familiar with Next.js App Router and TypeScript
  • Teams that already have a WordPress site with an accessible REST API and want a headless architecture
  • Projects that need optional WooCommerce product data integration
  • Projects planning to deploy to Vercel and manage configuration with environment variables

Getting started & customization

Use these recorded setup notes alongside the repository instructions for your chosen version.

  1. 1

    After cloning the repository, run npm install, then run the npm run setup wizard; alternatively, manually copy .env.example to .env.local and fill it in

  2. 2

    WP_URL must be set; for WooCommerce, create a read-only key in WooCommerce > Settings > Advanced > REST API and fill in WC_CONSUMER_KEY and WC_CONSUMER_SECRET

  3. 3

    In the WordPress admin, set permalinks to Post name and confirm /wp-json/wp/v2/posts is accessible and not blocked by a firewall

  4. 4

    To use /api/revalidate, set WP_REVALIDATE_SECRET; otherwise the endpoint returns 404

  5. 5

    When deploying to Vercel, import the repository, configure environment variables according to .env.example, and redeploy; the README does not provide deployment steps for other platforms

Read repository instructions

License & source material

Usage conditions & limitations

Free to use · keep license notice

This entry covers the free version under the MIT license in the public repository; the free scope is the code of this version and does not mean external services or third-party assets are free.

Must comply with when using

  • Free use, modification, commercial use, and distribution of this version's code are permitted.
  • When distributing copies or substantial portions of the code, retain the original author's copyright notice and the complete MIT license notice.
  • The code is provided as is; warranties and limitations of liability are governed by the original license and applicable law.

Additional costs & items to verify

  • Demo images, fonts, icons, and other third-party assets must be checked against their respective licenses and cannot be judged solely by the code's MIT license.
  • External services such as domains, hosting, databases, payments, or AI may incur separate charges.
  • The WP_URL environment variable must be configured to point to an accessible WordPress site REST API; otherwise the template cannot fetch content.
  • WooCommerce product functionality is optional and requires providing WC_CONSUMER_KEY to enable it.
  • WooCommerce product functionality is optional and requires providing WC_CONSUMER_SECRET to enable it.
  • Ensure the WordPress host or firewall does not block REST API requests; otherwise the frontend cannot read content.
  • Using WooCommerce functionality requires creating an API key with Read permission in the WooCommerce admin.
  • If WP_REVALIDATE_SECRET is not set, the /api/revalidate endpoint returns 404 and on-demand revalidation cannot be used.
  • The template does not include WordPress menu navigation integration by default; it must be implemented via a custom endpoint or plugin.
  • Menu navigation requires writing a custom endpoint or plugin yourself and adding a src/lib/menu.ts client.
View Original Text Basis

Permission is hereby granted, free of charge

Original License Text

- `WP_URL` (required)

Original README

- `WC_CONSUMER_KEY` (optional)

Original README

- `WC_CONSUMER_SECRET` (optional)

Original README

4. Ensure your hosting/firewall does not block REST API requests.

Original README

1. In WooCommerce, create API keys with **Read** permission:

Original README

If `WP_REVALIDATE_SECRET` is empty, endpoint returns `404` with a clear message.

Original README

This starter does not include WP menu ingestion by default.

Original README

Use a custom endpoint or plugin and add a small `src/lib/menu.ts` client as needed.

Original README
https://github.com/AndrewUru/wordpress-template/blob/main/LICENSEhttps://github.com/AndrewUru/wordpress-template/blob/main/README.md

Compiled by DeepSeek based on repository license and README ·2026-10-14. Results only cover the materials read; dependencies, images, fonts, and subsequent term changes are subject to their respective original texts.

Project checks & description sources

Template Information

Source platforms
GitHub
Documentation and maintenance reference score
More documented · 85 / 100
Technologies
Next.js · WordPress · React
Website type
Starter
How this score is calculated

Our heuristic uses license records (up to 30), a demo link (12), a preview (10), stars (15), recorded maintenance (15), description completeness (8), feature records (5) and classification data (5). It is not a code, security or performance test, or a Google score. A link does not establish tested functionality.

What to verify for this project

Repository update recorded
2026-02-26
Screenshot last checked
2026-10-14

A demo link is listed. Check it with your own content and viewport sizes; its presence does not confirm that forms, authentication or payments work.

The catalog identifies Next.js as the primary stack. Check the actual dependency manifest and lockfile for versions and hosting requirements. These notes use recorded metadata, not a code audit or a deployment test.

Use a selection guide →

How this description was prepared

AI-assisted description based on catalog records and repository material. Repository authors are not automatically the reviewers of this description.

Review declaration: codex-user-requested-batch-review-20261015 · 2026-10-15

Inspect the recorded source material

SHA-256: 2ae9a22d04e0192d7b0a85b36d898be1d649b1546dfdd1ffa76d9835e7321d89

2026-10-14T16:59:18.888Z

Source file / repository
# Next.js WordPress Headless Starter (WooCommerce Ready)

Production-ready template for building a **Next.js (App Router)** frontend with **WordPress Headless via REST API** and optional **WooCommerce REST API**.

Keywords: `nextjs wordpress starter`, `wordpress headless`, `woocommerce headless`, `next.js app router`, `wordpress rest api`, `vercel wordpress`.

![Node](https://img.shields.io/badge/Node-18%2B-339933?logo=node.js&logoColor=white)
![Next.js](https://img.shields.io/badge/Next.js-14-black?logo=nextdotjs)

## Use this template

1. Click **Use this template** on GitHub and create your new repository.
2. Clone your generated repository.

Or clone this repo directly:

```bash
git clone https://github.com/YOUR_ORG/next-wp-woo-headless-starter.git
cd next-wp-woo-headless-starter
```

## Quickstart

1. Install dependencies:

```bash
npm install
```

2. Run setup wizard:

```bash
npm run setup
```

3. Start dev server:

```bash
npm run dev
```

4. Open `http://localhost:3000`.

If you skip the wizard, copy `.env.example` to `.env.local` and fill values manually.

## Stack

- Next.js App Router
- TypeScript
- ESLint
- Minimal CSS (no UI framework)

## Environment variables

See `.env.example`:

- `WP_URL` (required)
- `WC_CONSUMER_KEY` (optional)
- `WC_CONSUMER_SECRET` (optional)
- `REVALIDATE_SECONDS` (default `60`)
- `WP_REVALIDATE_SECRET` (optional)
- `NEXT_PUBLIC_SITE_URL` (optional, used for sitemap/metadata)

## WordPress setup

1. In WordPress admin, go to **Settings > Permalinks**.
2. Set permalink structure to **Post name**.
3. Confirm REST API is reachable:

```bash
curl https://YOUR_WP_SITE/wp-json/wp/v2/posts
```

4. Ensure your hosting/firewall does not block REST API requests.

## WooCommerce setup (optional)

1. In WooCommerce, create API keys with **Read** permission:
   - WooCommerce > Settings > Advanced > REST API
2. Put keys in `.env.local`:
   - `WC_CONSUMER_KEY`
   - `WC_CONSUMER_SECRET`
3. Start app and open `/shop`.

If keys are not configured, `/shop` shows a friendly setup notice.

## Routes

- `/` Home (latest posts + featured products if Woo enabled)
- `/blog`
- `/blog/[slug]`
- `/page/[slug]`
- `/shop` (Woo optional)
- `/product/[slug]` (Woo optional)
- `/api/revalidate` (on-demand ISR)

## CPT auto-detection

The app reads `GET /wp-json/wp/v2/types` and filters public/viewable types from `wp/v2`.

Helpers:

- `getTypes()`
- `getEntries(typeSlug)`
- `getEntryBySlug(typeSlug, slug)`

By default, it does not create dynamic routes for all CPTs.

See [examples/cpt-route-example.md](examples/cpt-route-example.md) for an explicit route example.

## ACF support

If REST responses include `acf`, data is preserved in type definitions (`acf?: Record<string, any>`).

Included mapper example:

- `src/lib/mappers/hero.ts` (`mapHeroFromAcf`)
- `src/components/blocks/Hero.tsx`

In `/page/[slug]`, hero renders automatically when fields like `hero_title` exist.

No ACF plugin is required by this template; if `acf` is missing, nothing breaks.

## Revalidation

`/api/revalidate` supports:

- Secret via header: `x-revalidate-secret`
- Secret via query: `?secret=...`
- JSON body: `{ "tag": "...", "path": "..." }`

If `WP_REVALIDATE_SECRET` is empty, endpoint returns `404` with a clear message.

### Supported tags

- `wp:posts`
- `wp:pages`
- `wp:types`
- `wp:cpt:<type>`
- `woo:products`
- `woo:categories`

### curl examples

Revalidate by tag:

```bash
curl -X POST "http://localhost:3000/api/revalidate" \
  -H "content-type: application/json" \
  -H "x-revalidate-secret: YOUR_SECRET" \
  -d '{"tag":"wp:posts"}'
```

Revalidate by path:

```bash
curl -X POST "http://localhost:3000/api/revalidate?secret=YOUR_SECRET" \
  -H "content-type: application/json" \
  -d '{"path":"/blog"}'
```

Combined:

```bash
curl -X POST "http://localhost:3000/api/revalidate" \
  -H "content-type: application/json" \
  -H "x-revalidate-secret: YOUR_SECRET" \
  -d '{"tag":"woo:products","path":"/shop"}'
```

Webhook sample: [examples/webhook-revalidate-example.md](examples/webhook-revalidate-example.md)

## Deploy on Vercel

1. Import repo in Vercel.
2. Set environment variables from `.env.example`.
3. Redeploy after saving env vars.

Recommended production vars:

- `WP_URL`
- `REVALIDATE_SECONDS`
- `WP_REVALIDATE_SECRET`
- `NEXT_PUBLIC_SITE_URL`
- Woo vars if needed

## DX scripts

```bash
npm run dev
npm run lint
npm run typecheck
npm run setup
```

## Troubleshooting

### 401/403 from WordPress or WooCommerce

- Verify API keys and permissions.
- Check reverse proxy/firewall/CDN rules.
- Ensure application passwords/plugins are not overriding auth behavior.

### CORS or hosting restrictions

- Server-to-server fetches in Next.js usually avoid browser CORS issues.
- If WordPress blocks unknown user agents or origins, whitelist your Vercel/server IP ranges.

### Woo Basic Auth headers not accepted

- Some hosts strip `Authorization` headers.
- Test with `curl` directly against `/wp-json/wc/v3/products`.
- If header stripping happens, configure server to pass auth headers through.

### Missing menus/navigation from WordPress

This starter does not include WP menu ingestion by default.

Use a custom endpoint or plugin and add a small `src/lib/menu.ts` client as needed.

## License

MIT
Report a correction

Explore similar templates

Compare previews and descriptions within the same stack and category.