Headless hosting workflows
Published
Updated
🔗
Headless backend systems with frontend heads.
In a headless project, a PHP backend serves content through an API and a separate JavaScript frontend renders it. fortrabbit hosts the PHP backend and can serve a statically built frontend next to it.
Headless setup
- Backend: a PHP framework such as Laravel or Symfony, or a CMS such as Craft CMS, Kirby or Statamic, exposes content through a REST or GraphQL API.
- Frontend: a JavaScript framework such as Vue, Nuxt, React or Next.js fetches the content and renders the pages.
Several frontends can share one backend. The price is two systems to build, deploy and keep in sync.
Hosting options
fortrabbit runs PHP. Node.js is available in the build commands, not as a server at runtime. That leaves two ways to host a headless project:
| Setup | Backend | Frontend |
|---|---|---|
| Separate | fortrabbit environment | Frontend host such as Netlify or Vercel |
| Together | fortrabbit environment | Built statically during deployment, served from the same environment |
Together, frontend and backend can share one repository, see monorepos. For other ways to map frontend and backend to apps and environments, see project organization.
Rendering modes
How the frontend renders decides what search engines see and where the frontend can run:
| Mode | HTML is created | Runs on fortrabbit |
|---|---|---|
| CSR, client-side rendering | In the browser | Yes |
| SSG, static site generation | At build time | Yes |
| SSR, server-side rendering | On each request, by a Node.js server | No |
| ISR, incremental static regeneration | At build time, then refreshed in the background by a Node.js server | No |
CSR suits apps behind a login, since search engines see little content. SSG serves fast static HTML, but content changes need a new build: trigger one from the CMS with a deploy hook.
Performance
A full static build queries every page of the backend at once. On a large site with many images, that creates a load peak on the backend during each deployment. GraphQL makes it easy to write queries that fetch far more than a page needs; check slow queries in the backend before blaming the server.