Launch from local server

To simplify game development and testing, you can run it from a local server. Testing is available in prod and dev environments.

When running the game locally, you can use all SDK functions from it.

Prod environment

Alert

Requires registration on the Yandex Games platform and a game draft.

Suitable for the final testing phase before submitting for moderation. In this mode, the game interacts with the actual Yandex Games platform.

Features:

  • The game opens at a real address on yandex.com/games.
  • To send requests to external hosts, they must be added to CSP rules.
  • Displays real ads.
  • Players authenticate via Yandex Passport.
  • Player data and leaderboards are stored on the server.
  • The product catalog loads from the server; purchases are processed server-side.
  • For debugging, use the debug panel via the URL parameter &debug-mode=16.

You can configure local game launch in prod environment:

Manual local server setup

  1. Set up a localhost server.
  2. Open the game in draft mode.
  3. Add the parameter ?game_url=https://localhost to the address.

Note

For security reasons, only the localhost domain is supported in the game_url parameter.

Setting up a local server using an npm package

  1. Install npm by following the instructions on Node.JS.

  2. Use npm to install the @yandex-games/sdk-dev-proxy package:

    npm install -g @yandex-games/sdk-dev-proxy
    
  3. Launch the game. You can:

    npx @yandex-games/sdk-dev-proxy -h <Local server address>
    
    npx @yandex-games/sdk-dev-proxy -p <Path to game folder>
    

    The package proxies SDK resource requests to the same server where your game will be hosted.

If you specify the --app-id parameter, the game will open on yandex.com/games:

npx @yandex-games/sdk-dev-proxy -p <Path to game folder> --app-id=<Game ID>

If --app-id isn't specified, the console will display a template link to the game on the service and a link to the local server.

Launch parameters

Parameter

Description

--help

Help.

--host, -h

Host where the local game server is located (e.g., used for webpack-dev-server).

--path, -p

Path to the folder containing game resources.

--port

Port for the server (default: 8080).

--app-id, -i

Game draft ID.

--csp, -c

Adds a meta tag with Content-Security-Policy. Matches the tag that will be created in index.html on the service.

--log, -l

Enables request logging in the console (enabled by default).

--tld

Changes the domain yandex.tld, e.g., to yandex.com (default: ru).

--dev-mode

If true, launches the game in dev environment (default: false, which corresponds to prod environment).

Dev environment

Note

Registration on the Yandex Games platform and a game draft are not required.

Ideal for active development and debugging of game logic. In this mode, the game has no real connection to the Yandex Games platform, and all SDK calls are replaced with mocks, allowing quick page reloads to see updates.

Features:

  • The game opens directly at https://localhost.
  • No CSP restrictions — requests can be sent to any external hosts.
  • Ads are replaced with placeholders, though all callback functions work similarly to prod environment.
  • Player authentication uses a mock browser dialog.
  • Player data and leaderboards are stored in localStorage.
  • The product catalog loads from a local file; player purchases are saved to localStorage.
  • For debugging, you can set parameters via the browser's address bar.
  • The browser console automatically logs all SDK calls, grouped by module.

Dev environment launch is also available via the npm package @yandex-games/sdk-dev-proxy. Setup instructions are identical to prod environment, but you must specify the --dev-mode=true parameter when launching.

You can:

npx @yandex-games/sdk-dev-proxy -h <Local server address> --dev-mode=true
npx @yandex-games/sdk-dev-proxy -p <Path to game folder> --dev-mode=true

Available browser address bar parameters

export interface SDKMocks {
    /** Is adding a desktop shortcut allowed? */
    canShowPrompt?: boolean;
    /** Is the player authorized? */
    isAuthorized?: boolean;
    /** If the game's orientation is locked. */
    lockedOrientation?: ELockedOrientation;
}

/** Locked game orientation on mobile screens. */
export enum ELockedOrientation {
    /** Game only supports landscape. */
    LANDSCAPE = 'landscape',
    /** Game supports both orientations. */
    NONE = 'none',
    /** Game only supports portrait. */
    PORTRAIT = 'portrait',
}

Example

localhost:8080?mocks={"canShowPrompt":true,"isAuthorized":true,"lockedOrientation":"landscape"}

Local product catalog setup

To emulate a product catalog, create a purchases-catalog.json file in the project root and add a list of purchases — identical to what you've already added or plan to add in the Developer Console. In dev mode, the SDK will load purchases from this file.

Example

[
    {
        "description": "Well styled modern avatar image",
        "id": "avatar",
        "imageURI": "{path-to-image}",
        "price": "100 RUB",
        "priceCurrencyCode": "RUB",
        "priceValue": "100",
        "title": "Premium avatar",
        "getPriceCurrencyImage": "return ''"
    }
]

When a purchase is initiated, a mock dialog will show options for successful purchase and cancellation, letting you test both scenarios.

Landscape orientation.

Portrait orientation.

Artificial objects or functions simulating real ones. Used for testing code without external dependencies.

In '', you can insert an image path.

Previous