vkma.devRU

How to test and publish an HTML5 game on VK

On this page

This guide covers VK Games, the HTML5 games that run inside VK. The separate VK Play distribution platform uses a different publishing process. If you already have a game, add VKWebAppInit to its entry point and skip to hosting.

1. Build a minimal game

The score button checks that the HTML and JavaScript loaded. The line below it shows separately whether the official VK Bridge replied to VKWebAppInit. That helps distinguish a broken game build from a failed VK connection.

mkdir vk-clicker
cd vk-clicker
npm init -y
npm install @vkontakte/vk-bridge
npm install -D vite
HTMLindex.html
<!doctype html>
<html lang="en">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>VK Clicker</title>
    <button id="score" type="button">Score: 0</button>
    <p id="bridge-status" role="status">Opened outside VK</p>
    <script type="module" src="./main.js"></script>
</html>
JSmain.js
import bridge from "@vkontakte/vk-bridge";

if (!bridge.isStandalone()) {
    const status = document.querySelector("#bridge-status");
    status.textContent = "Waiting for VK Bridge…";
    void bridge
        .send("VKWebAppInit")
        .then(() => {
            status.textContent = "VK Bridge replied to VKWebAppInit";
        })
        .catch(error => {
            status.textContent = "VKWebAppInit failed";
            console.error("VKWebAppInit:", error);
        });
}

const button = document.querySelector("#score");
let score = 0;
button.addEventListener("click", () => {
    score += 1;
    button.textContent = `Score: ${score}`;
});
npx vite build --base=./
npx vite preview

Open the local address from the terminal. Clicking the button should increase the score, while the line below should say “Opened outside VK.” When launched inside VK, the same line should confirm the reply to VKWebAppInit. Publish the contents of dist/. The relative asset paths also work when hosting the game in a subdirectory.

2. Register and host the game

  1. In the VK developer dashboard, choose Create app → Game. Enter the name and genre, and save the game ID.
  2. Host the contents of dist/ over public HTTPS. Use VK Games static hosting or your own HTTPS server. Open the URL directly and check that the HTML and assets load.
  3. In Settings → Placement, set the URL for the platforms you want to support. To test privately, enable development mode and set a separate development URL. Copy the game link from the dashboard and open it as an administrator.

3. Test the game and submit it for review

  • The direct URL works, but the game will not open in VK on the web. Check the console for iframe restrictions. Your X-Frame-Options and Content-Security-Policy: frame-ancestors headers must allow the VK host to embed the game.
  • The game works in a browser but fails on a phone. Check the mobile platform URL, confirm the certificate is trusted, and make sure all assets load over HTTPS. Open the game link inside the VK mobile client.
  • There is no response to VKWebAppInit. Make sure you launched the game inside VK. The VKMA Devtools extension can inspect the actual message exchange on desktop.

Uploading the files and listing the game in the catalog are separate steps. Once the game works, prepare the description, icon, and screenshots, then follow the VK Games catalog submission process. For launch requirements and platform differences, see the official VK Games guide.

vkma.dev
RU
Esc