You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|[apollo-authentication](next/apollo-authentication)| Showcases authentication with Next.js, Apollo Client, and Headless WordPress. |
18
-
|[apollo-client-data-fetch](next/apollo-client-data-fetch)| Explores data fetching strategies and state management using Next.js, Apollo Client, and Headless WordPress. |
19
-
|[apollo-client-filesystem-routing](next/apollo-client-filesystem-routing)| Integrates WPGraphQL and WPGraphQL for ACF with Next.js for a headless WordPress site. |
20
-
|[client-app-router-fetch-data](next/client-app-router-fetch-data)| Uses Next.js App Router and fetch API to retrieve data from WordPress via WPGraphQL. |
21
-
|[client-multisite-app-router-fetch-data](next/client-multisite-app-router-fetch-data)| Implements a multisite headless WordPress app with Next.js App Router and fetch API. |
22
-
|[custom-sitemap-apollo](next/custom-sitemap-apollo)| Generates a custom sitemap using Next.js, Apollo Client, and WPGraphQL with an extended plugin. |
23
-
|[custom-sitemap-vanilla-wpgraphql](next/custom-sitemap-vanilla-wpgraphql)| Creates a custom sitemap using Next.js and WPGraphQL without extending its endpoints. |
24
-
|[hybrid-sitemap-apollo](next/hybrid-sitemap-apollo)| Fetches and transforms WordPress sitemaps for clean URL formatting with Next.js. |
25
-
|[proxied-sitemap-apollo](next/proxied-sitemap-apollo)| Provides a proxied sitemap by transforming WordPress XML sitemaps for SEO-friendly frontend URLs. |
26
-
|[proxied-graphql-debug](next/proxied-graphql-debug)| Provides a proxied GraphQL API for development, enabling response inspection and query complexity analysis. |
27
-
|[render-blocks-pages-router](next/render-blocks-pages-router)| Renders WordPress Blocks with JSX in Next.js, including utilities for hierarchical block data. |
|[apollo-authentication](next/apollo-authentication)| Showcases authentication with Next.js, Apollo Client, and Headless WordPress. |
18
+
|[apollo-client-data-fetch](next/apollo-client-data-fetch)| Explores data fetching strategies and state management using Next.js, Apollo Client, and Headless WordPress. |
19
+
|[apollo-client-filesystem-routing](next/apollo-client-filesystem-routing)| Integrates WPGraphQL and WPGraphQL for ACF with Next.js for a headless WordPress site. |
20
+
|[client-app-router-fetch-data](next/client-app-router-fetch-data)| Uses Next.js App Router and fetch API to retrieve data from WordPress via WPGraphQL. |
21
+
|[client-multisite-app-router-fetch-data](next/client-multisite-app-router-fetch-data)| Implements a multisite headless WordPress app with Next.js App Router and fetch API. |
22
+
|[custom-sitemap-apollo](next/custom-sitemap-apollo)| Generates a custom sitemap using Next.js, Apollo Client, and WPGraphQL with an extended plugin. |
23
+
|[custom-sitemap-vanilla-wpgraphql](next/custom-sitemap-vanilla-wpgraphql)| Creates a custom sitemap using Next.js and WPGraphQL without extending its endpoints. |
24
+
|[hybrid-sitemap-apollo](next/hybrid-sitemap-apollo)| Fetches and transforms WordPress sitemaps for clean URL formatting with Next.js. |
25
+
|[proxied-sitemap-apollo](next/proxied-sitemap-apollo)| Provides a proxied sitemap by transforming WordPress XML sitemaps for SEO-friendly frontend URLs. |
26
+
|[proxied-graphql-debug](next/proxied-graphql-debug)| Provides a proxied GraphQL API for development, enabling response inspection and query complexity analysis. |
27
+
|[render-blocks-pages-router](next/render-blocks-pages-router)| Renders WordPress Blocks with JSX in Next.js, including utilities for hierarchical block data. |
28
+
|[wp-theme-rendered-blocks](next/wp-theme-rendered-blocks)| Demonstrates how to fetch and apply WordPress Global Styles in a Next.js project using the `globalStylesheet` GraphQL field. |
|[template-hierarchy-data-fetching-urql](sveltekit/template-hierarchy-data-fetching-urql)| Demonstrates template hierarchy and data fetching with SvelteKit, URQL, and Headless WordPress. |
34
-
|[wp-theme-rendered-blocks](next/wp-theme-rendered-blocks)| Demonstrates how to fetch and apply WordPress Global Styles in a Next.js project using the `globalStylesheet` GraphQL field. |
|[template-hierarchy-data-fetching-urql](sveltekit/template-hierarchy-data-fetching-urql)| Demonstrates template hierarchy and data fetching with SvelteKit, URQL, and Headless WordPress. |
|[nuxt-headlesswp-gravity-forms](nuxt/nuxt-headlesswp-gravity-forms)| Shows you how to wire up a full headless WordPress backend—complete with Gravity Forms, WPGraphQL, and a pre-built "Questionnaire" form—alongside a Nuxt 3 front end. |
35
41
36
42
## Contributing
37
43
38
44
If you feel like something is missing or you want to add an example for another framework, we encourage you to contribute! Please check out our [Contributing Guide](https://github.com/wpengine/hwptoolkit/blob/main/CONTRIBUTING.md) for more details.
39
45
46
+
### Best practices for the new examples
47
+
48
+
You can copy on of existing examples to use it as a _skeleton_ of your new example. The guide below explains the key parts our standard example format.
49
+
50
+
1.**Project Structure**
51
+
52
+
Organize your project with a clear separation between the frontend application and the WordPress environment configuration.
53
+
54
+
```bash
55
+
.
56
+
├── example-app/ # Front-end code
57
+
│ └── ...
58
+
├── .wp-env.json # Configuration for the local WordPress environment
59
+
└── wp-env/
60
+
└── db/
61
+
└── database.sql # Initial database state
62
+
```
63
+
64
+
2.**Local WordPress with wp-env**
65
+
66
+
Use wp-env to create a local, containerized WordPress environment. Create a .wp-env.json file in your project root and include all of the required plugins and config to make your example work:
"wp:db:export": "wp-env run cli -- wp db export /var/www/html/db/database.sql",
103
+
"wp:db:import": "wp-env run cli -- wp db import /var/www/html/db/database.sql",
104
+
"wp-env": "wp-env"
105
+
},
106
+
```
107
+
108
+
4.**Documentation (README.md)**
109
+
110
+
A clear README.md with essential information would guide the new developers effectively and reduce the errors. Consider including the information below:
111
+
112
+
- Prerequisites: Node.js, Docker.
113
+
114
+
- Setup Steps: A simple list on how to clone, install dependencies, and run the start script.
115
+
116
+
- Demo Credentials: Provide login details for the local WordPress admin (/wp-admin). Default for wp-env is admin / password.
117
+
118
+
- Security implications, and other considerations for the users, if applicable.
119
+
120
+
- Don't forget to include your example to this common README file as well, inside one of the tables above.
121
+
40
122
## Screenshots
41
123
42
124
> **Feature Highlight:** Here are some sample screenshots of the examples listed above.
|`example:build`| Prepares the environment by unzipping images, starting WordPress, importing the database, and starting the application. |
75
+
|`example:build`| Prepares the environment by starting WordPress, importing the database, and starting the application. |
77
76
|`example:dev`| Runs the Next.js development server. |
78
77
|`example:dev:install`| Installs the required Next.js packages. |
79
78
|`example:start`| Starts WordPress and the Next.js development server. |
@@ -85,8 +84,6 @@ Congratulations, WordPress should now be fully set up.
85
84
|`wp:db:query`| Executes a database query within the WordPress environment. |
86
85
|`wp:db:export`| Exports the WordPress database to `wp-env/db/database.sql`. |
87
86
|`wp:db:import`| Imports the WordPress database from `wp-env/db/database.sql`. |
88
-
|`wp:images:unzip`| Extracts the WordPress uploads directory. |
89
-
|`wp:images:zip`| Compresses the WordPress uploads directory. |
90
87
91
88
> **Note** You can run `npm run wp-env` and use any other wp-env command. You can also see <https://www.npmjs.com/package/@wordpress/env> for more details on how to use or configure `wp-env`.
|`example:build`| Prepares the environment by unzipping images, starting WordPress, importing the database, and starting the application. |
107
+
|`example:build`| Prepares the environment by starting WordPress, importing the database, and starting the application. |
111
108
|`example:dev`| Runs the Next.js development server. |
112
109
|`example:dev:install`| Installs the required Next.js packages. |
113
110
|`example:start`| Starts WordPress and the Next.js development server. |
@@ -119,10 +116,8 @@ Congratulations, WordPress should now be fully set up.
119
116
|`wp:db:query`| Executes a database query within the WordPress environment. |
120
117
|`wp:db:export`| Exports the WordPress database to `wp-env/db/database.sql`. |
121
118
|`wp:db:import`| Imports the WordPress database from `wp-env/db/database.sql`. |
122
-
|`wp:images:unzip`| Extracts the WordPress uploads directory. |
123
-
|`wp:images:zip`| Compresses the WordPress uploads directory. |
124
119
125
-
> **Note** You can run `pnpm wp-env` and use any other wp-env command. You can also see <https://www.npmjs.com/package/@wordpress/env> for more details on how to use or configure `wp-env`.
120
+
> **Note** You can run `npm run wp-env` and use any other wp-env command. You can also see <https://www.npmjs.com/package/@wordpress/env> for more details on how to use or configure `wp-env`.
0 commit comments