SDK
Install and quick start
One script, about ten lines, and your game joins VPlay.
Install
Load the SDK from the address below. Do not bundle a copy: loading it from here means fixes reach your game within minutes.
ES module
import { VPlay } from "https://vplay.gg/sdk/v1/vplay-sdk.js";Or with a plain script tag:
Script tag
<script src="https://vplay.gg/sdk/v1/vplay-sdk.global.js"></script>
<!-- sets window.VPlay -->Everything is served from one folder:
SDK files
https://vplay.gg/sdk/v1/vplay-sdk.js the SDK as an ES module
https://vplay.gg/sdk/v1/vplay-sdk.global.js the same SDK for a plain script tag
https://vplay.gg/sdk/v1/vplay-sdk.d.ts TypeScript types
https://vplay.gg/sdk/v1/example-game.html a small game that uses every call
https://vplay.gg/sdk/v1/test-host.html a stand-in for VPlay, for testingQuick start
JavaScript
const vp = await VPlay.init({
gameId: "your-game-id",
// Only while testing a local build; remove before launch:
// hostOrigins: ["http://localhost:3000"],
});
if (vp.mode === "vplay") {
showPrices(vp.items); // prices come from VPlay
showBalance(vp.vcoins); // display only
loadSave(vp.save); // cloud save, or null
}
VPlay.loading(1); // 0..1 while assets load
VPlay.gameplayStart(); // the player is actually playing
VPlay.milestone("ach.first-delivery");
const bought = await VPlay.purchase("skin.amber");
const result = await VPlay.gameOver({ score: 4200, level: 3 });
VPlay.saveCloud({ level: 3 }); // up to 64 KB, saved for you
VPlay.on("pause", pauseGame);
VPlay.on("resume", resumeGame);Standalone always works. Outside VPlay,
init resolves with mode: "standalone" and every other call does nothing. Never make gameplay depend on the SDK succeeding.