Passing parameters to play canvas


I’ve just started using PlayCanvas and was wondering if its possible to pass in parameters through GET or POST when loading the game? We are making a game that has lots of user interaction at the front end which we are building in HTML 5/Javascript and want to trigger PlayCanvas from user input. From this, we need to pass across some parameters to initialise the 3D component of our game.

Thanks in advanced,


1 Like

If you are hosting on, you can use query parameters in the URL, and they will be available in javascript as usual, e.g. as

Thanks for the quick response Dave,

What happens if we are hosting the game somewhere else? We are aiming to host this on our own server with the rest of the application. Does that change where these parameters are available?



If you’re hosting the application yourself, it’s up to you how you integrate it. PlayCanvas games are just a client-side javascript application so you can interface with them however you like.

Hi, here is a good function I found for grabbing url parameters:

function getURLParameter(name) {
  return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec( || [null, ''])[1].replace(/\+/g, '%20')) || null;

So you can use:

myvar = getURLParameter('myvar');