# Vue & Svelte

> Add Shipabase to a Vue or Svelte app built with Vite, or to SvelteKit.

Source: https://shipabase.dev/docs/vue-svelte

## Vue or Svelte with Vite

`Terminal`

```bash
npm i @shipabase/js
```

Call `init` at the top of `src/main.ts`, before the app is mounted.

`src/main.ts`

```ts
import { init } from "@shipabase/js";

init(import.meta.env.VITE_SHIPABASE_KEY, { appVersion: import.meta.env.VITE_APP_VERSION });
```

## SvelteKit

Call `init` in `onMount` of the root layout, so it only runs in the browser.

`src/routes/+layout.svelte`

```svelte
<script>
  import { onMount } from "svelte";
  import { init } from "@shipabase/js";
  import { PUBLIC_SHIPABASE_KEY } from "$env/static/public";

  onMount(() => init(PUBLIC_SHIPABASE_KEY));
</script>

<slot />
```

## Track events

`anywhere`

```ts
import { trackEvent } from "@shipabase/js";

trackEvent("project_created", { plan: "pro" });
```
