WordPress Setup
Follow these steps to prepare your WordPress site for WPNuxt.
Step 1: Install WPGraphQL (Required)
WordPress doesn't expose a GraphQL API by default. WPGraphQL adds one, which WPNuxt uses to fetch your content with type safety and auto-generated composables.
- In WordPress Admin, go to Plugins → Add New
- Search for WPGraphQL or download it here
- Click Install Now, then Activate
Step 2: Configure WPGraphQL Settings
In WordPress Admin → GraphQL → Settings, configure:
| Setting | Value | Why |
|---|---|---|
| GraphQL Endpoint | /graphql | Default, matches WPNuxt config |
| Enable Introspection | Yes | Introspection lets WPNuxt query the GraphQL schema itself — discovering all available types, fields, and queries — so it can generate TypeScript types and validate your .gql files at build time. Without introspection enabled, pnpm nuxt prepare fails with a schema download error |
| Public Introspection | Yes | Required during development so WPNuxt can download the schema without authentication |
- Recommended: Set
schemaAuthToken(or theWPNUXT_SCHEMA_AUTH_TOKENenv var) to a WPGraphQL authentication token. WPNuxt sends this as a Bearer token during build-time schema operations, so introspection works without being publicly exposed. See Securing Introspection below. - Set
downloadSchema: falseand commitschema.graphqlto your repository. You must manually update the schema file whenever your WordPress schema changes.
usePostByUri, useNodeByUri) require "pretty" permalinks. Go to Settings → Permalinks and select Post name or any non-plain structure. With "Plain" permalinks, WordPress returns no URI paths and these composables return null. See Troubleshooting for more details.Step 3: Install WPGraphQL Content Blocks (Optional)
The standard GraphQL API returns post content as a single HTML string. This plugin exposes individual Gutenberg blocks as structured data, so @wpnuxt/blocks can render each block with its own Vue component.
Required only if you use @wpnuxt/blocks to render Gutenberg blocks as Vue components.
- Download from WPGraphQL Content Blocks
- In WordPress Admin, go to Plugins → Add New → Upload Plugin
- Upload the zip file and click Activate
This exposes block data in the GraphQL schema so @wpnuxt/blocks can render them.
Step 4: Install Headless Login for WPGraphQL (Optional)
WordPress authentication uses cookies tied to the WordPress domain. This plugin adds JWT-based authentication to WPGraphQL, enabling login flows from your Nuxt frontend.
Required only if you use @wpnuxt/auth for WordPress authentication.
- Download from Headless Login for WPGraphQL
- In WordPress Admin, go to Plugins → Add New → Upload Plugin
- Upload the zip file and click Activate
After installation, configure providers in WordPress Admin → GraphQL → Headless Login:
- Enable the Password provider for username/password authentication
- Optionally configure OAuth providers (Google, GitHub, etc.) for social login
See the Authentication Guide for detailed setup instructions.
Securing Introspection
By default, WPGraphQL exposes the schema publicly. This is fine during development, but in production you may want to disable Public Introspection to hide your schema from unauthenticated users.
WPNuxt supports authenticated schema introspection via the schemaAuthToken option. When configured, WPNuxt sends the token as a Bearer header during build-time operations (endpoint validation and schema download), allowing introspection to work without public access.
Setup
- In WordPress Admin, go to GraphQL → Settings
- Keep Enable Introspection set to Yes
- Set Public Introspection to No
- Generate an application password or authentication token for a WordPress user with sufficient permissions
- Add the token to your environment:
WPNUXT_SCHEMA_AUTH_TOKEN=your-auth-token
Or set it directly in nuxt.config.ts:
wpNuxt: {
wordpressUrl: 'https://wordpress.example.com',
schemaAuthToken: process.env.WPNUXT_SCHEMA_AUTH_TOKEN
}
schemaAuthToken is only used at build time for schema operations. It is never included in client bundles or runtime requests. For runtime authentication, use @wpnuxt/auth.Verify Your Setup
Visit https://your-site.com/graphql in a browser. You should see the GraphQL IDE.
Try this query:
{
posts {
nodes {
title
}
}
}
If you see your posts, WordPress is ready. Continue to Installation.
Summary
| Plugin | Required For | Install Link |
|---|---|---|
| WPGraphQL | All WPNuxt projects | WordPress plugin directory |
| WPGraphQL Content Blocks | @wpnuxt/blocks only | GitHub releases |
| Headless Login for WPGraphQL | @wpnuxt/auth only | GitHub releases |