Skip to content

zardoy/vk-params

Repository files navigation

VK Params · npm version GitHub top language semantic-release

A small helper for working with VK launch params [ru]. Useful for vk-mini-apps.

Usage

import { vkGetParam } from "@zardoy/vk-params";

// No vk_ prefix needed
vkGetParam("app_id");
//=> 6739175

vkGetParam("are_notifications_enabled");
//=> false

API

vkGetParam(param)

Return value depends on param argument.

It is important to know, that if appropriate param in url doesn't exist this function will throw an Error.

vkIsDesktopVersion(): boolean

Shortcut for vkGetParam("platform") === "desktop_web".

paramNames

Array of names all VK launch params.

nullableParamNames

Same as previous, but contains only params that may not exist in url.

Things to note

  • If you are using React, you should use Error Boundary in the root of your app.
  • For proper typings support, use TypeScript v4 or higher.

Stats, file list and more package details

Please, let me know if you find a better alternative to this module.