Integrating Prismic into Your Existing SvelteKit Project


Create Sveltekit Project
npm create svelte@latest .
This will create sveltekit project in existing directory
Create Prismic repository using the prismic website
Prismic Website

Prismic | Create New Repository
Create Slice Machine.

Prismic | Get started with slice machine
Click on “I already have a project”.

Prismic will guide you on how to connect to its platform.

Prismic | Set up slice machine
npx @slicemachine/init@latest --repository [repositoryName]
If you know the repository name
or
npx @slicemachine/init@latest
If you don't know your repository name
5a. Prismic will prompt you to press any key to initiate a browser-based login
5b. Then, Prismic will prompt you to run the Slice Machine; press 'Y' to proceed.
5c. Now, Prismic will open the Slice Machine tab at localhost:9999
If you want to run the slice machine manually, run
npm run slicemachine
Let's create a PAGE (Single-use Component) In my case I'm using a template from prismic
On the top right, press Page Snippet
Follow the instructions
Open prismic on the browser
https://[repositoryName].prismic.io/documents
Create your first content and publish the content

Improve caching and performance in SvelteKit by importing images from src/lib instead of static. Learn why and how this approach works.