Skip to main content

Vue / Browser — Initialization

Use @signal-js/browser with Vue, Vanilla JS, Svelte, Angular, or any JavaScript framework. Install the package, create a Signal instance with createSignal(), and call await signal.start() when your app is ready.

Installation

npm install @signal-js/browser
No framework-specific package is required. The same API works in all browser environments.

Vue setup

Initialize Signal in your Vue app (e.g. in onMounted or a composable). Create one instance and call start() once.
<script setup>
import { onMounted } from 'vue'
import { createSignal } from '@signal-js/browser'

let signal = null

onMounted(async () => {
  signal = createSignal({
    apiKey: 'your-api-key',
    projectId: 'your-project-id',
    // endpoint is optional (defaults to https://api.trysignal.ai/)
  })
  
  await signal.start()
})
</script>
Then use signal.capture(), signal.identify(), etc. in methods or composables.

Vanilla JS

Same API in plain HTML/JS or with a bundler:
<script type="module">
  import { createSignal } from '@signal-js/browser';

  const signal = createSignal({
    apiKey: 'your-api-key',
    projectId: 'your-project-id',
    // endpoint is optional (defaults to https://api.trysignal.ai/)
  });

  await signal.start();
</script>
With Vite or webpack, import once at app entry and reuse the instance wherever you track events.

Other frameworks

  • Svelte — Call createSignal() in onMount or at module scope; pass the instance where needed.
  • Angular — Create the client in a service or APP_INITIALIZER and inject it where you track events.
  • Any other framework — One createSignal(options) call, then await signal.start(). Use signal.capture(), signal.identify(), and the rest of the API as needed.

Next steps