Getting Started with Faust
To create a Faust project, run:
npx create-next-app \
-e https://github.com/wpengine/faustjs/tree/main \
--example-path examples/next/faustwp-getting-started \
cd into your new app and copy the sample environment template:
cp .env.local.sample .env.local
Finally, run the dev server:
npm run dev
You can now visit http://localhost:3000 to see your new project.
Currently, the posts and pages you see are coming from our WordPress site at https://faustexample.wpengine.com. In the next step, we'll show you how to hook up your own WordPress site.
Connecting Your WordPress Site
The example app above loads WordPress content from the demo site at https://faustexample.wpengine.com.
To point it to a different WordPress site, first, make sure you have installed and activated the necessary WordPress plugins:
Once the necessary plugins have been installed, open the
.env.local file you created earlier, it should look something like this:
# Your WordPress site URL
# Plugin secret found in WordPress Settings->Headless
If you are using a version of Faust previous to 0.2.1, use
FAUSTWP_SECRET_KEY instead of
NEXT_PUBLIC_WORDPRESS_URL value with your WordPress site URL (be sure to include
Additionally, update the
FAUST_SECRET_KEY value with the secret key found in Settings → Faust in your WordPress admin area to support previews.
Note for Atlas Users: if deploying from the Atlas portal using your own repository without beginning with a blueprint, you will need to set your environment variables manually. Learn how by taking a look at our FAQs.
Set your Front-end Site URL
To ensure certain features of Faust function as expected, such as previews, be sure to set the Front-end Site URL in the Faust WordPress Plugin Settings. It is the URL to your headless front-end. This is used for authenticated post previews and for rewriting links to point to your front-end site.
- Navigate to the
Faust WordPress Pluginsettings page
- Enter in the base url of your headless WordPress site, i.e. http://localhost:3000 or http://www.mysiteurl.com in the Front-end site URL setting
Check Your Permalinks
Finally, ensure your permalink structure in
WP Admin -> Settings -> Permalinks is not set to "plain":
Faust resolves templates similar to the Template Hierarchy in WordPress, but "plain" permalinks are not supported due to constraints in Next.js.
With your project created and development environment started, edit
wp-templates/front-page.js and see the updated results in your browser.
Continue learning about the project structure, how to change styles, layout, etc. by referencing the Example Project Walkthrough Structure.