viakite
Dashboard

SDKs/Overview/SDKs and libraries

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/sdk from npm, and call init() 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

SDKInstallForStatus
Script tag<script defer src="https://us.api.vk.viabio.me/v1/a.js" …>Any websiteAvailable
JavaScriptnpm install @viakite/sdkAny browser app with a bundlerAvailable
Next.js@viakite/sdk/reactApp Router and Pages RouterAvailable
React@viakite/sdk/reactVite, React Router and other React appsAvailable
Vue and Nuxt@viakite/sdk/vueVue 3.3 and later, NuxtAvailable
Svelte and SvelteKit@viakite/sdk/svelteSvelte 5, SvelteKitAvailable
React Native@viakite/react-nativeiOS and Android apps, Expo and bareAvailable
Node.js@viakite/nodeEvents from your Node.js serverAvailable
Gogithub.com/viakite/viakite-goEvents from your Go serverBuilt, not published yet
CLISource maps, logs and updates from the terminalComing 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: true and the title prop do the same thing (Options);
  • track(), identify() and reset() from @viakite/sdk work 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.

Next steps