Everything you need to build a SvelteKit project with Contentful. This starter shows you how to:
- Fetch data from the Contentful GraphQL API
- Create dynamic routes
- Use the Svelte component Lifecycle
- Display a map using Google Maps
- Use private Environment Variables server-side
Clone this repository
git clone https://github.com/contentful/sveltekit-starter.git
Install dependencies.
npm install
Create a Contentful account with an empty space. Go to your Contentful space and
- Find your Space ID
- Create an access token for the Content Delivery API
- Create an access token for the Content Management API.
- Rename the
.env.example
at the root of your project to.env
(so it is ignored by Git). - In the new
.env
file, replaceYOUR_SPACE_ID
,YOUR_DELIVERY_TOKEN
andYOUR_MANAGEMENT_ACCESS_TOKEN
with the values from the previous step.
The project comes with a Contentful set up command that imports the required content model and adds sample content to your space.
Run the following command to import the content model.
npm run setup
npm run dev
This will start the development server and open the app in a new browser tab.
The page will reload when you make changes.
To create a production version of your app:
npm run build
You can preview the production build with npm run preview
.
To deploy your app, you may need to install an adapter for your target environment.