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.gitInstall dependencies.
npm installCreate 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.exampleat the root of your project to.env(so it is ignored by Git). - In the new
.envfile, replaceYOUR_SPACE_ID,YOUR_DELIVERY_TOKENandYOUR_MANAGEMENT_ACCESS_TOKENwith 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 setupnpm run devThis 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 buildYou can preview the production build with npm run preview.
To deploy your app, you may need to install an adapter for your target environment.