Skip to main content
Fully automated. The CLI writes a composable and calls it in main.ts.

Install with the CLI

npx @lucenthq/cli init luc_pk_...
Pick Vue when prompted.

Manual setup

1

Environment variable

.env:
VITE_LUCENT_PUBLIC_KEY=luc_pk_...
2

Composable

src/composables/useLucent.ts:
import { LucentTracker } from "@lucenthq/sdk";

let tracker: LucentTracker | null = null;

export function useLucent() {
  if (!tracker) {
    tracker = new LucentTracker({
      publicKey: import.meta.env.VITE_LUCENT_PUBLIC_KEY,
    });
    tracker.start();
  }
  return tracker;
}
3

Initialize in main.ts

src/main.ts:
import { createApp } from "vue";
import App from "./App.vue";
import { useLucent } from "./composables/useLucent";

useLucent();

createApp(App).mount("#app");

Notes

  • Vue doesn’t need a provider because tracking is handled by the LucentTracker instance directly — the composable just guarantees a single instance.
  • To access the tracker from a component, import useLucent and call it — it returns the same singleton each time.