Use Game Servers with this tutorial.

Documentation pages that include this code sample

To view the code sample used in context, see the following documentation:

Code sample


To learn how to install and use the client library for Game Servers, see the Game Servers Client Libraries.

const {RealmsServiceClient} = require('@google-cloud/game-servers');

async function quickstart() {
  const client = new RealmsServiceClient();

  // TODO(developer): uncomment the following section, and add values
  // const projectId = 'YOUR_PROJECT_ID';
  // const location = 'us-central1;
  // const realmId = 'DESIRED_REALM_ID';

  const request = {
    parent: `projects/${projectId}/locations/${location}`,
    realm: {
      // Must use a valid support time zone.
      // See https://cloud.google.com/dataprep/docs/html/Supported-Time-Zone-Values_66194188
      timeZone: 'US/Pacific',
      description: 'My Game Server realm',

  const [operation] = await client.createRealm(request);
  const results = await operation.promise();
  const [realm] = results;

  console.log('Realm created:');

  console.log(`\tRealm name: ${realm.name}`);
  console.log(`\tRealm description: ${realm.description}`);
  console.log(`\tRealm time zone: ${realm.timeZone}`);