Running a game from a local server

To facilitate development and testing of your game, you can run the game on your local server. To do this:

  1. Add your game's draft using the Yandex Games Console.
  2. Set up your localhost server.
  3. Open the game in draft mode by adding the ?game_url=https://localhost parameter to the URL.

Note

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

Setting up a local server

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

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

    > $ npm install -g @yandex-games/sdk-dev-proxy
    
  3. Run your game. To do this, you can:

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

    The package proxies the requests to the SDK resources hosted on the same server as your game.

If you want to run your game at yandex.com/games, specify the --app-id parameter:

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

If you omit the --app-id parameter, the console shows the default link to your game on Yandex Games and the link to your local server.

After the game launches on the local server, you can use all the SDK features from it.

Launch parameters

Parameter

Description

--help

Shows the help message.

--host, -h

Hostname for your local game server (for example, this parameter is used for the webpack-dev-server module).

--path, -p

Path to your game's source folder.

--port

Port to access the server (the default port is 8080).

--app-id, -i

Game draft ID.

--csp, -c

Adds the meta tag with the Content-Security-Policy header. This meta tag corresponds to the tag that will be added to the index.html file on Yandex Games.

--log, -l

Enables logging of requests to the console (enabled by default).

--tld

Changes the extension in the yandex.tld domain, for instance, to yandex.com (ru is the default domain extension).