---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://yandex.com/dev/games/doc/en/concepts/local-launch.md
  - https://yandex.com/dev/games/doc/hi/concepts/local-launch.md
  - https://yandex.com/dev/games/doc/ko/concepts/local-launch.md
  - https://yandex.com/dev/games/doc/ru/concepts/local-launch.md
  - https://yandex.com/dev/games/doc/tr/concepts/local-launch.md
  - https://yandex.com/dev/games/doc/vi/concepts/local-launch.md
  - https://yandex.com/dev/games/doc/zh/concepts/local-launch.md
  - href: en/concepts/local-launch.md
    type: text/markdown
    title: Markdown version
  - href: ../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/games/doc/en/llms.txt

# Launch from local server

<!-- source: en/_includes/script-common.md -->
<!-- source: en/_includes/script/index-js.md -->

<!-- endsource: en/_includes/script/index-js.md -->

<!-- source: en/_includes/script/requirements-js.md -->

<!-- endsource: en/_includes/script/requirements-js.md -->

<!-- source: en/_includes/script/image-modal-js.md -->

<!-- endsource: en/_includes/script/image-modal-js.md -->
<!-- endsource: en/_includes/script-common.md -->

To simplify game development and testing, you can run it from a local server. Testing is available in [prod](#prod-env) and [dev environments](#dev-env).

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



## Prod environment {#prod-env}

{% note alert %}

Requires [registration](https://yandex.com/dev/games/doc/en/console/manage-account.md) on the Yandex Games platform and a [game draft](https://yandex.com/dev/games/doc/en/console/add-new-game.md#create-draft).

{% endnote %}

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](https://yandex.com/games){.external}.
- To send requests to external hosts, they must be [added](https://yandex.com/dev/games/doc/en/console/add-new-game.md#check-host) 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](https://yandex.com/dev/games/doc/en/console/debug-panel.md) via the URL parameter `&debug-mode=16`.

You can configure local game launch in prod environment:
- [Manually](#self-setup)
- [Using an npm package](#setup-localhost)

### Manual local server setup {#self-setup}

1. Set up a `localhost` server.
1. Open the game in [draft mode](https://yandex.com/dev/games/doc/en/console/test-game.md).
1. Add the parameter `?game_url=https://localhost` to the address.

{% note info %}

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

{% endnote %}

### Setting up a local server using an npm package {#setup-localhost}

1. Install `npm` by following the instructions on [Node.JS](https://nodejs.org/en/){.external}.
1. Use `npm` to install the [@yandex-games/sdk-dev-proxy](https://www.npmjs.com/package/@yandex-games/sdk-dev-proxy){.external} package:

    ```console
    npm install -g @yandex-games/sdk-dev-proxy
    ```

1. Launch the game. You can:

   {% list tabs %}

   - Proxy to a local server

      ```console
      npx @yandex-games/sdk-dev-proxy -h <Local server address>
      ```

   - Specify the game resources folder

       ```console
       npx @yandex-games/sdk-dev-proxy -p <Path to game folder>
       ```

   {% endlist %}

   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](https://yandex.com/games){.external}:

```console
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 {#start-params}

#|
|| **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](https://yandex.com/dev/games/doc/en/concepts/languages-and-domains.md) `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 {#dev-env}

{% note info %}

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

{% endnote %}

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](*mock), 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](#local-catalog-set); player purchases are saved to `localStorage`.
- For debugging, you can set [parameters](#available-params) 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](https://www.npmjs.com/package/@yandex-games/sdk-dev-proxy){.external}. Setup instructions are identical to [prod environment](#setup-localhost), but you must specify the `--dev-mode=true` parameter when launching.

You can:

{% list tabs %}

   - Proxy to a local server

      ```console
      npx @yandex-games/sdk-dev-proxy -h <Local server address> --dev-mode=true
      ```

   - Specify the game resources folder

       ```console
       npx @yandex-games/sdk-dev-proxy -p <Path to game folder> --dev-mode=true
       ```

{% endlist %}

#### Available browser address bar parameters {#available-params}

```ts showLineNumbers
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 = 'landscape',
    /** Game supports both orientations. */
    NONE = 'none',
    /** Game only supports [portrait](*portrait). */
    PORTRAIT = 'portrait',
}
```

**Example**

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

#### Local product catalog setup {#local-catalog-set}

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](https://games.yandex.com/console){.external}. In dev mode, the SDK will load purchases from this file.

**Example**

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

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

[*landscape]: Landscape orientation.

[*portrait]: Portrait orientation.

[*mock]: Artificial objects or functions simulating real ones. Used for testing code without external dependencies.

[*return]: In `''`, you can insert an image path.