Install Prismic
By the end of this page, you will have a SvelteKit project set up with basic utilities from Prismic.
This article explains how to install and configure Prismic in a SvelteKit project. By the end of this page, you will have Prismic utilities installed in your app.
Quickstart from the dashboard
To start building quickly, go to prismic.io/dashboard, select SvelteKit, and choose a starter.
Start from scratch
This guide assumes basic knowledge of Svelte and SvelteKit. If you are new to development with either, see the official introductions for Svelte and SvelteKit.
Create a SvelteKit project
Before proceeding, you will need a SvelteKit project. You can quickly create a brand new project using the following create-svelte
command. (Read the official documentation to learn more):
npm create svelte@latest
This command will prompt an option to name your project. After that you’ll be able to open your newly created SvelteKit app.
Once it’s finished, you’ll have a brand new SvelteKit project where you can install Slice Machine.
Run the setup command
In the root of your SvelteKit project, run the following command:
npx @slicemachine/init@latest
Configure Prismic
The init
script creates a file called prismicio.js
in the src/lib/
directory of your project. This file contains configurations for your project.
The most important configuration is the routes
array, which is your route resolver. Update the route resolver to match the routing structure of your SvelteKit app. To learn more about how to add configurations, see the documentation for the route resolver and @prismicio/client
.
The prismicio.js
file is prefilled with an example routes array:
const routes = [
{
type: "homepage",
path: "/",
},
{
type: "page",
path: "/:uid",
},
];
In prismicio.js
, customize the routes
array to match the routing of your project. For each page type, add an object that describes the route for that page. Learn more about how the route resolver works.
You now have Prismic utilities available throughout your project.
Now you can start creating slices and types to model your project.