Environment Variables
Properly configuring environment variables is crucial for enabling the NextWP to WordPress connection. These variables facilitate secure communication and access to specific WordPress functionalities.
- Setup for Local and Production Environments: Set these variables in a
.env.local
file in your project's root for local development. For production, configure them in your hosting provider's environment settings. - Application Password for Enhanced Access: Generate this in WordPress (Users > Your Profile > Application Passwords) to securely access extended features like menus and site settings.
- Align Preview and Revalidate Secrets: Ensure these match the corresponding values in your WordPress's NextWP Toolkit plugin settings, crucial for draft mode previews and on-demand revalidation.
Remember to handle these variables, especially in production environments, with strict security measures to prevent unauthorized access.
Example .env.local
You can quickly copy these randomly generated example variables to your .env.local
. Make sure to enter the same values in your WordPress's NextWP Toolkit plugin settings.
.env.local
NEXT_SITE_URL=
NEXT_PUBLIC_WP_URL=
WP_APPLICATION_PASSWORD=
NEXT_PREVIEW_SECRET=
REVALIDATE_SECRET_KEY=
Environment Variables
- Name
NEXT_SITE_URL
- Type
- string
- Description
The URL of your frontend site.
Example:https://example.com
- Name
NEXT_PUBLIC_WP_URL
- Type
- string
- Description
The URL of your WordPress site used to fetch the WP REST API.
Example:https://example-wordpress.com
- Name
WP_APPLICATION_PASSWORD
- Type
- string
- Description
The application password used to authenticate with WordPress when fetching things like menus, site settings and options pages.
You can generate an application password in WordPress admin dashboard under Users > Your Profile > Application Passwords.
Example:username: IXdM LkSK EysQ F5Cs 9TbA pvvt
- Name
NEXT_PREVIEW_SECRET
- Type
- string
- Description
The secret used to authenticate WordPress page previews to the Next.js draft mode preview route.
This should match the value set for preview secret in the NextWP Toolkit Plugin settings.
- Name
REVALIDATE_SECRET_KEY
- Type
- string
- Description
- A secret key used to revalidate pages in Next.js content updates in WP.
The revalidate route handler is designed to work with the On-Demand Revalidation plugin.