SDKs and libraries
Which one to use, and what each covers
Viakite has one SDK for the web: @viakite/sdk. You can load it as a script tag, import it from npm, or add it as a component in Next.js, React, Vue or Svelte. All of them run the same code, take the same options and send the same events, so pick the one that fits how your site is built.
Which one to use
- A site without a build step (plain HTML, WordPress, Shopify, Webflow): the script tag. One line in the
<head>. - An app built with Next.js, React, Vue or Svelte: the
<Analytics />component for your framework. Add it once at the root of the app. - Any other app with a bundler:
@viakite/sdkfrom npm, and callinit()once in your entry file.
Not sure? The script tag works on every site. The dashboard's Install page gives you the snippet for each way with your key filled in; see Install Analytics.
Every SDK and library
| SDK | Install | For | Status |
|---|---|---|---|
| Script tag | <script defer src="https://us.api.vk.viabio.me/v1/a.js" …> | Any website | Available |
| JavaScript | npm install @viakite/sdk | Any browser app with a bundler | Available |
| Next.js | @viakite/sdk/react | App Router and Pages Router | Available |
| React | @viakite/sdk/react | Vite, React Router and other React apps | Available |
| Vue and Nuxt | @viakite/sdk/vue | Vue 3.3 and later, Nuxt | Available |
| Svelte and SvelteKit | @viakite/sdk/svelte | Svelte 5, SvelteKit | Available |
| React Native | @viakite/react-native | iOS and Android apps, Expo and bare | Available |
| Node.js | @viakite/node | Events from your Node.js server | Available |
| Go | github.com/viakite/viakite-go | Events from your Go server | Built, not published yet |
| CLI | Source maps, logs and updates from the terminal | Coming soon |
All of them send to Viakite Analytics. Monitoring, Logs and Updates are coming soon; the plan is for them to use the same SDKs.
@viakite/sdk runs in the browser only. To send events from your server, such as a payment webhook, use a secret key: see Server-side events.
One core for all of them
The framework packages are thin. <Analytics /> for React, Vue and Svelte calls init() once in the browser, after mounting, and renders nothing. Its props are the options of init(). The script tag reads its data-* attributes into the same options and calls the same init().
This means:
- every option has the same name and default everywhere:
data-title,title: trueand thetitleprop do the same thing (Options); track(),identify()andreset()from@viakite/sdkwork next to any component, and a page holds one copy of the SDK even when you import both;- page changes in a single-page app are followed through the browser's history, which every router above uses. One page view per new path, none when only the query changes.
React, Vue and Svelte are optional peer dependencies: install only the one you use.
Small, safe and quiet
- Under 3 KB. The script tag is under 3 KB gzipped. A check in CI fails the build when it grows past that.
- Never throws. Every function catches its own errors. A missing or wrong key turns tracking off; it never breaks your page. In debug mode you see why in the console.
- Safe on the server. On the server (no
window), every function does nothing, so you can import it in server-side rendered code. The components start only in the browser. - No cookies. Nothing is stored on the visitor's device and no consent banner is needed. See Privacy.