Your first Livedeck widget: from the starter kit to the upload
Download the starter kit, change it, upload it as a ZIP and test it in the editor.
The starter kit is a finished widget called "Live Feed": it shows gifts, follows and chat as cards and counts the likes. Build your own from there.
What's in the package
manifest.json
Name, version, size, permissions and settings of the widget
index.html
The start page. It loads the SDK and your files.
style.css
The look
app.js
The logic: reacts to events
README.md
Quick guide
| File | Purpose |
|---|---|
| manifest.json | Name, version, size, permissions and settings of the widget |
| index.html | The start page. It loads the SDK and your files. |
| style.css | The look |
| app.js | The logic: reacts to events |
| README.md | Quick guide |
The start page
Every start page loads the SDK from the path /sdk/v1.js. Livedeck serves it at your widget's address; you don't put it into the package yourself. Load all your other files with relative paths.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
<!-- Livedeck serves the SDK. Everything else lives in your package. -->
<script src="/sdk/v1.js"></script>
</head>
<body>
<div id="feed"></div>
<script src="app.js"></script>
</body>
</html>Reacting to events
function show(text) {
const line = document.createElement("p");
line.textContent = text; // textContent, never innerHTML: names are viewer text
document.getElementById("feed").prepend(line);
}
livedeck.on("gift", (e) => {
// "@" + e.user.handle (username), e.gift.name, e.count, e.totalDiamonds
show("@" + e.user.handle + " sent " + e.count + "× " + e.gift.name);
});
livedeck.on("follow", (e) => {
show("@" + e.user.handle + " followed you");
});
livedeck.ready(() => {
// The overlay is connected and the settings are here.
document.body.style.color = livedeck.settings.accent;
});A widget only gets the events it asks for under permissions in manifest.json. For the example above that is events.gift and events.follow.
Zip and upload
- Raise the version in manifest.json (for example from 1.0.0 to 1.0.1) so you can tell your versions apart later.
- Zip the files. manifest.json must be at the top of the ZIP or inside the one folder that holds everything. Windows: select the files › right-click › Send to › Compressed (zipped) folder. Mac: select the files › right-click › Compress.
- In the dashboard: Editor › My widgets › "Upload your own". The first time you create a developer profile and accept the rules.
- After about a minute the check is done. Didn't pass? You see every reason with file and line, or with the measured value. Fix it and upload a new ZIP.
- Place the widget on the canvas and try it with the test buttons in its settings (gift, chat, likes and more).
Was this article helpful?