Svelte
@picked/svelte lets the Picked client render Svelte components, and gives functions and
components to read the client from Svelte.
| Peer dependency | Version |
|---|---|
svelte | ^5.55.7 |
@picked/client | The version of your Picked SDK |
effector | ^23.4.4 |
Entry points
| Import | Exports |
|---|---|
@picked/svelte | adaptSvelteComponent, isValidAdaptedComponent, setPickedContext, ExperienceSlot, HtmlRender, LazyImage |
@picked/svelte/plugins/framework | svelteFrameworkPlugin |
@picked/svelte/plugins/devtools | svelteDevtoolsPlugin |
@picked/svelte/hooks | getPicked, getExperience, getStep, getStepContent, getStepLayoutContent, setStepContext, getFeature, getFeatureResult, getFeatureEnabled, getPredicate, getPredicateResult, getAction, getActionResult, getContent, getReference, getReferences, createQuery, createSessionStorageStore, createLocalStorageStore, useUnit |
@picked/svelte/router | StepRouter, Step |
@picked/svelte/form | getForm |
@picked/svelte/server | renderer, 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: {} })],
})| Option | Type | Default | Description |
|---|---|---|---|
components | { experience?: { component, style? } } | required | experience renders each experience that has no component of its own. |
stylesheets | string[] | none | The URLs of stylesheets to add to each shadow root. |
css | string[] | none | CSS text to add to each shadow root. |
Devtools plugin
svelteDevtoolsPlugin connects the client to the Picked Chrome extension.
| Option | Type | Default | Description |
|---|---|---|---|
enabled | boolean | false | When true, the devtools open on page load. When false, the Chrome extension opens them. |
customTools | CustomTool[] | [] | 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.
