> For the complete documentation index, see [llms.txt](https://docs.ecwid.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ecwid.com/site-themes/develop-site-themes/sections/client.md).

# Client

The `client.ts` file is the client-side entry point for your section. It handles **hydration** — taking the server-rendered HTML and making it interactive in the browser by attaching Vue's reactivity system and event listeners.

### How It Works <a href="#how-it-works" id="how-it-works"></a>

When a page loads, the server-rendered HTML is displayed immediately. The client entry point then:

1. Initializes a Vue app instance with your section component
2. Mounts it onto the existing server-rendered DOM (hydration)
3. Handles live updates when merchants edit content/design in the Editor
4. Unmounts cleanly when the section is removed

### Usage <a href="#usage" id="usage"></a>

```typescript
// client.ts
import { createVueClientApp } from '@lightspeed/crane-api';
import Section from './Section.vue';
import type { Content, Design } from './type';

export default createVueClientApp<Content, Design>(Section);
```

The generic parameters `<Content, Design>` provide type safety for the state passed during mount and update cycles.

### Extensions <a href="#extensions" id="extensions"></a>

`createVueClientApp` accepts an optional second argument for hooking into the app lifecycle:

```typescript
createVueClientApp<Content, Design>(Section, {
  init(app) {
    // Called after the Vue app is created, before mounting.
    // Use this to register plugins, directives, or global components.
  },
  mount(app, rootContainer, state) {
    // Called just before the app mounts to the DOM.
    // Access the initial state (context, content, design data).
  },
  update(app, state) {
    // Called when content or design data changes (e.g., merchant edits in the Editor).
  },
  unmount(app) {
    // Called before the app is unmounted.
    // Clean up any resources not managed by Vue.
  },
});
```

All extension callbacks are optional.

{% hint style="info" %}
For most sections, the basic usage without extensions is sufficient. Extensions are useful when you need to register Vue plugins, set up third-party libraries, or manage resources outside Vue's lifecycle.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ecwid.com/site-themes/develop-site-themes/sections/client.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
