Svelte SDK best practices
Developer preview
Use TypeScript. The SDK is TypeScript-first. Define
Propsinterfaces usingComponentProps<T>for all components with proper types for each parameter.Use
componentMapoverresolveRenderer. The declarative component map is simpler, more readable, and easier to maintain than a resolver function. ReserveresolveRendererfor cases where your own code has to pick the component.Download manifest before build. Use
npm run pull:manifest && vite buildto ensure the manifest is always up-to-date. Never commit a stale manifest.Run
publish:manifestafter changes. Always rununiform context manifest publishafter modifying signals, enrichments, or quirks. The manifest must be re-downloaded after publishing.Use
flattenValuesfor assets. Always useflattenValuesfrom@uniformdev/canvasfor asset parameters rather than manually traversing the parameter structure.Access
componentprop for metadata. When you need raw parameter data, component IDs, variant info, or slot information, use thecomponentprop.Use
getScores()andgetQuirks()for reactive data. Accessingcontext.scoresdirectly does not trigger re-renders. Always use the reactive helpers for values that affect the UI.Keep the preview handler in place. The preview API endpoint and server hooks are required for visual editing in the Uniform Canvas editor. Do not remove them.
Use
edgetogether with the NESI hook.outputType="edge"without the hook insrc/hooks.server.tsleaves the placeholders in the HTML. Usestandardwhen you do not run that hook.Use the
type__variantnaming convention. For variant-specific component mappings, use double underscore (hero__dark) in the component map rather than creating separate resolver logic.