How to use Primo Headless

This guide is about accessing a Primo site’s content from a framework. To render Primo pages from within your existing SvelteKit codebase, read using Primo with SvelteKit.

You can access your site from any frontend framework by fetching its site file from its deployed repository.

A site file is a JSON file deployed with Primo sites which has the properties of “site, pages, sections, symbols”. It defines the entire site and is rarely larger than half a megabyte but can inflate if storing a lot of content or code.

Example

In this SvelteKit repository, we can see the site file being fetched directly from the site’s repository in order to hydrate some content in the application (in this case blog posts). It gets the list of blog posts from the list of child pages of Blog. Since the content is fetched from the server, it loads fully rendered.