{"id":25008458,"url":"https://github.com/thomasgauvin/swa-with-headless-wordpress","last_synced_at":"2026-04-16T03:32:38.211Z","repository":{"id":211587443,"uuid":"729524891","full_name":"thomasgauvin/swa-with-headless-wordpress","owner":"thomasgauvin","description":"Sample Static Web Apps site with headless Wordpress on App Service","archived":false,"fork":false,"pushed_at":"2024-02-13T14:31:57.000Z","size":48,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-04T02:43:45.027Z","etag":null,"topics":["appservice","nextjs","staticwebapps","wordpress"],"latest_commit_sha":null,"homepage":"https://icy-ground-0c1fd4210.4.azurestaticapps.net/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thomasgauvin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-12-09T14:02:18.000Z","updated_at":"2024-10-07T14:21:30.000Z","dependencies_parsed_at":"2023-12-09T15:23:54.035Z","dependency_job_id":"2316ea1c-b00e-4d76-b867-0f55667e8891","html_url":"https://github.com/thomasgauvin/swa-with-headless-wordpress","commit_stats":null,"previous_names":["thomasgauvin/swa-with-headless-wordpress"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thomasgauvin/swa-with-headless-wordpress","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasgauvin%2Fswa-with-headless-wordpress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasgauvin%2Fswa-with-headless-wordpress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasgauvin%2Fswa-with-headless-wordpress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasgauvin%2Fswa-with-headless-wordpress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomasgauvin","download_url":"https://codeload.github.com/thomasgauvin/swa-with-headless-wordpress/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasgauvin%2Fswa-with-headless-wordpress/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31870508,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"online","status_checked_at":"2026-04-16T02:00:06.042Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["appservice","nextjs","staticwebapps","wordpress"],"created_at":"2025-02-05T02:59:09.850Z","updated_at":"2026-04-16T03:32:38.183Z","avatar_url":"https://github.com/thomasgauvin.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Building an Azure Static Web Apps site using WordPress on App Service as a headless CMS\n\nThis is a sample project that demonstrates how to build a static web app using WordPress as a headless CMS and deployed to Azure Static Web Apps. This project uses Next.js to build the static web app pulling content from the WordPress REST APIs. This repository complements the blog on this topic: [Build an Azure Static Web Apps site using WordPress as a headless CMS](https://techcommunity.microsoft.com/t5/apps-on-azure-blog/building-an-azure-static-web-apps-site-using-wordpress-on-app/ba-p/4004955). \n\n## Getting Started\n\nFirst, run the development server:\n\n```bash\nnpm run dev\n```\n\nOpen [http://localhost:3000](http://localhost:3000) with your browser to see the result.\n\nYou can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.\n\n## Understand how this project uses WordPress as a headless CMS\n\nLet's take for instance the BlogPage component located at `app\\post\\[slug]\\page.tsx`. This component is responsible for fetching the content from WordPress and rendering it. The `getStaticProps` function is responsible for fetching the content from WordPress. Let's take a look at the code:\n\n```tsx\nconst wordpressUrl = process.env.WORDPRESS_URL;\n\nexport async function generateStaticParams(){\n  const response = await fetch(`${wordpressUrl}/wp-json/wp/v2/posts?_fields[]=slug`);\n  const posts : Post[] = await response.json();\n  const paths = posts.map(post =\u003e ({\n    slug: post.slug \n  }));\n  return paths;\n}\n```\n\nIn the above code snippet, we are accessing the WORDPRESS_URL that is accessible as an environment variable and defined in the .env file. This will be used as a build-time environment variable to fetch the content from WordPress.\n\nWe then make a fetch request to the WordPress REST API to fetch the content of the post. The `slug` is passed as a parameter to the function and is used to fetch the content of the post. \n\nThe same is done for WordPress pages. Once we have this content, we can decide to render it how we want. More information on the available WordPress REST API endpoints can be found [here](https://developer.wordpress.org/rest-api/reference/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasgauvin%2Fswa-with-headless-wordpress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomasgauvin%2Fswa-with-headless-wordpress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasgauvin%2Fswa-with-headless-wordpress/lists"}