# Contextual editing with the Svelte SDK

> How the Svelte SDK supports visual editing in Canvas, and how to set up contextual editing yourself.

Source: https://docs.uniform.app/docs/sdk/svelte/contextual-editing

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

The SDK provides built-in support for Uniform's visual/contextual editing. When a composition is opened in the Uniform Canvas editor, the SDK automatically:

1. Listens for composition update messages from the editor
2. Re-renders the component tree with the updated data
3. Enables inline editing for `UniformText` and `UniformRichText` components
4. Annotates components with editing attributes for the Canvas UI

## `getUniformContextualEditing`

For custom contextual editing setups, use `getUniformContextualEditing` directly:

```svelte
<script lang="ts">
  import { getUniformContextualEditing } from '@uniformdev/canvas-svelte';

  const { composition, isContextualEditing } = getUniformContextualEditing({
    initialCompositionValue: compositionData,
    enhance: (message) => message.composition,
  });
</script>
```

| Return Value | Type | Description |
| --- | --- | --- |
| `composition` | reactive `RootComponentInstance` | The current composition (updates during editing) |
| `isContextualEditing` | reactive `boolean` | Whether the app is in contextual editing mode |
