Skip to content

Quick Start

Prerequisites

  • A web server
  • A domain name

You really just need a place to host an HTML page, and if you'd like other people to have access to your application, you'll need a domain name. There are a million guides on the internet about how to host a simple website, so for the purposes of this guide, I'll assume you're squared away in that department.

Create an account

First, head to the Developer Hub to register your application. You'll need to enter the URL where you plan to host your application.

To start, you'll likely be testing your application locally, so entering a URL like http://localhost:3000 is perfectly acceptable.

Install GameGlue

Include GameGlue in your project using one of the following options:

sh
npm i gamegluejs
sh
yarn add gamegluejs
html
<script src="https://unpkg.com/gamegluejs@0.0.10/dist/gg.sdk.js"></script>

Initialize the SDK

javascript
const ggClient = new GameGlue({
  clientId: '<your-application-id>',
  redirect_uri: '<your-application-url>',
  scopes: ['<your-required-scopes>']
});

Authenticate the user

javascript
await ggClient.auth();
const userId = ggClient.getUserId();

Create a listener

javascript
const userListener = await ggClient.createListener({
  userId: userId,
  gameId: '<your-game-id>'
});

Subscribing to specific fields

To reduce bandwidth, you can subscribe to only the fields you need:

javascript
const userListener = await ggClient.createListener({
  userId: userId,
  gameId: 'msfs',
  fields: ['ground_speed', 'indicated_altitude', 'true_heading']
});

If you don't specify fields, you'll receive all available telemetry data.

Use the listener

javascript
userListener.on('update', (evt) => {
  document.body.innerHTML = evt.data.ground_speed;
});

Dynamic subscriptions

You can add or remove fields at runtime without reconnecting:

javascript
// Add more fields
await userListener.subscribe(['fuel_quantity_gallons', 'eng_rpm_1']);

// Remove fields you no longer need
await userListener.unsubscribe(['true_heading']);

// Check current subscriptions
const currentFields = userListener.getFields();

That's it! Please reach out to support@gameglue.gg if you have any questions, or suggestions.