# Svelte SDK best practices

> Recommendations for building Uniform components, personalization, and manifests with the Svelte and SvelteKit SDK.

Source: https://docs.uniform.app/docs/sdk/svelte/best-practices

> **Developer preview:**
>
> This feature is in developer preview and may change unexpectedly. For more information, contact support@uniform.dev.

1. **Use TypeScript.** The SDK is TypeScript-first. Define `Props` interfaces using `ComponentProps<T>` for all components with proper types for each parameter.
2. **Use `componentMap` over `resolveRenderer`.** The declarative component map is simpler, more readable, and easier to maintain than a resolver function. Reserve `resolveRenderer` for cases where your own code has to pick the component.
3. **Download manifest before build.** Use `npm run pull:manifest && vite build` to ensure the manifest is always up-to-date. Never commit a stale manifest.
4. **Run `publish:manifest` after changes.** Always run `uniform context manifest publish` after modifying signals, enrichments, or quirks. The manifest must be re-downloaded after publishing.
5. **Use `flattenValues` for assets.** Always use `flattenValues` from `@uniformdev/canvas` for asset parameters rather than manually traversing the parameter structure.
6. **Access `component` prop for metadata.** When you need raw parameter data, component IDs, variant info, or slot information, use the `component` prop.
7. **Use `getScores()` and `getQuirks()` for reactive data.** Accessing `context.scores` directly does not trigger re-renders. Always use the reactive helpers for values that affect the UI.
8. **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.
9. **Use `edge` together with the NESI hook.** `outputType="edge"` without the [hook](https://docs.uniform.app/docs/sdk/svelte/personalization-and-testing#edge-personalization) in `src/hooks.server.ts` leaves the placeholders in the HTML. Use `standard` when you do not run that hook.
10. **Use the `type__variant` naming convention.** For variant-specific component mappings, use double underscore (`hero__dark`) in the component map rather than creating separate resolver logic.
