Query a Sanity CMS from a SvelteKit Blog Frontend with +page.server.js

InstructorBen Patton

Share this video with your friends

Send Tweet

We will install the @sanity/client package and use the GROQ query language to query all of our posts from our CMS.

To do this in SvelteKit we need to make a few adjustments to how we load data. We now need a async load function that runs on the server because sanity needs to access our environment variables. To do this we'll convert our +page.js to +page.server.js and make our function async.