Skip to content
LogoLogo

Svelte

@picked/svelte lets the Picked client render Svelte components, and gives functions and components to read the client from Svelte.

Peer dependencyVersion
svelte^5.55.7
@picked/clientThe version of your Picked SDK
effector^23.4.4

Entry points

ImportExports
@picked/svelteadaptSvelteComponent, isValidAdaptedComponent, setPickedContext, ExperienceSlot, HtmlRender, LazyImage
@picked/svelte/plugins/frameworksvelteFrameworkPlugin
@picked/svelte/plugins/devtoolssvelteDevtoolsPlugin
@picked/svelte/hooksgetPicked, getExperience, getStep, getStepContent, getStepLayoutContent, setStepContext, getFeature, getFeatureResult, getFeatureEnabled, getPredicate, getPredicateResult, getAction, getActionResult, getContent, getReference, getReferences, createQuery, createSessionStorageStore, createLocalStorageStore, useUnit
@picked/svelte/routerStepRouter, Step
@picked/svelte/formgetForm
@picked/svelte/serverrenderer, which renders a Svelte component to HTML on the server

Framework plugin

svelteFrameworkPlugin registers Svelte as a framework of the client. The client then renders each Svelte component in a shadow root.

import { createClient } from 'picked'
import { svelteFrameworkPlugin } from '@picked/svelte/plugins/framework'
 
const client = createClient({
  projectId: 'your-project-id',
  plugins: [svelteFrameworkPlugin({ components: {} })],
})
OptionTypeDefaultDescription
components{ experience?: { component, style? } }requiredexperience renders each experience that has no component of its own.
stylesheetsstring[]noneThe URLs of stylesheets to add to each shadow root.
cssstring[]noneCSS text to add to each shadow root.

Devtools plugin

svelteDevtoolsPlugin connects the client to the Picked Chrome extension.

OptionTypeDefaultDescription
enabledbooleanfalseWhen true, the devtools open on page load. When false, the Chrome extension opens them.
customToolsCustomTool[][]Your own tools, which show in the Custom Tools tab.

When a preview token is there, the devtools launcher shows, even if enabled is false. See How to debug with the Chrome extension.

Components

adaptSvelteComponent(component) makes a Svelte component that the client can render. It takes a component, a dynamic import, or a lazy loader. See How to register a component.