- Notifications
You must be signed in to change notification settings - Fork0
sanity-io/sanity-sveltekit
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
The Official Sanity toolkit for SvelteKit applications.
Inside your existing SvelteKit application, install@sanity/sveltekit:
npm install @sanity/sveltekit
See theVisual Editing with SvelteKit guide for a full implementation.
Create and populate a.env.local file at the root of your application if it does not already exist.
# .env.localPUBLIC_SANITY_PROJECT_ID=<your-project-id>PUBLIC_SANITY_DATASET=<your-dataset-name>
Create asanity.config.ts file.
// src/lib/sanity.config.tsimport{defineConfig}from'sanity';import{structureTool}from'sanity/structure';import{PUBLIC_SANITY_PROJECT_IDasprojectId,PUBLIC_SANITY_DATASETasdataset}from'$env/static/public';exportdefaultdefineConfig({basePath:'/studio',// `basePath` must match the route of your Studio projectId, dataset,plugins:[structureTool()],schema:{types:[]}});
Next, create a catch all route usingrest parameters
<!-- src/routes/studio/[...catchall]/+page.svelte --><scriptlang="ts">importconfigfrom'$lib/sanity/sanity.config';import {SanityStudio }from'@sanity/sveltekit';</script><SanityStudio {config} />
Note: When embedding a studio in your application, you should wrap the rest of your routes in a(group) to separate your studio and user-facing application layouts.
@sanity/sveltekit exports Sanity client and groq related helper functions directly, no need to install separate dependencies.
import{createClient,defineQuery,groq}from'@sanity/sveltekit';
About
Resources
Code of conduct
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.