Skip to main content

getWordPressProps Reference

getWordPressProps is a function that should be returned within Next.js' getStaticProps or getServerSideProps to properly setup the Faust Template Hierarchy system.

Usage

To properly configure getWordPressProps, create pages/[...wordpressNode].js with the following content:

pages/[...wordpressNode].js
import { getWordPressProps, WordPressTemplate } from '@faustwp/core';

export default function Page(props) {
return <WordPressTemplate {...props} />;
}

export function getStaticProps(ctx) {
return getWordPressProps({ ctx });
}

export async function getStaticPaths() {
return {
paths: [],
fallback: 'blocking',
};
}
note

This above example uses getStaticProps, but you can alternatively use getServerSideProps if you'd like.

Config

Below is the getWordPressProps config object defined as a TypeScript type:

type GetWordPressPropsConfig<Props = Record<string, unknown>> = {
/**
* The Next.js getServerSideProps or getStaticProps context. This is required.
*/
ctx: GetServerSidePropsContext | GetStaticPropsContext;
/**
* Any props you would like returned to the Faust templates
*/
props?: Props;
/**
* The Next.js revalidate value. By default, Faust sets a smart default of 900 seconds (15 minutes)
*/
revalidate?: number | boolean;
};