This guide provides step-by-step instructions on how to install and initialize the Userorbit SDK in a Vue.js application, covering both npm/yarn and CDN installation, initialization with Vue 3 Composition API (and Vue 2 Options API), and user identification after authentication. It also includes verification steps to ensure successful integration.
Install
userorbit-js in a Vue application and initialize it after the app mounts.Install
npm install userorbit-jsBashInitialize
import { onMounted } from "vue";
import userorbit from "userorbit-js";
onMounted(() => {
void userorbit.init({ accountId: "YOUR_ACCOUNT_ID" });
});TypeScriptIdentity
After authentication, callidentify(userId, { email, name, attributes }). Call logout() when the user signs out.Vue Router
Automatic History API detection normally handles navigation. If a targeted experience does not re-evaluate, callregisterRouteChange() from router.afterEach.