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
- Set up a
localhost
server. - Open the game in draft mode.
- 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
-
Install
npm
by following the instructions on Node.JS. -
Use
npm
to install the @yandex-games/sdk-dev-proxy package:npm install -g @yandex-games/sdk-dev-proxy
-
Launch the game. You can:
Proxy to a local serverSpecify the game resources foldernpx @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. |
|
Host where the local game server is located (e.g., used for |
|
Path to the folder containing game resources. |
|
Port for the server (default: 8080). |
|
Game draft ID. |
|
Adds a meta tag with |
|
Enables request logging in the console (enabled by default). |
|
Changes the domain |
|
If |
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.