A starter template for creating custom TagoIO widgets using Svelte!
Hopefully coming soon: automated deployment
TagoIO is an IoT platform that lets you build dashboards and widgets with real device data. You can build your own custom widgets, which TagoIO then loads in an iframe and injects data into.
I love Svelte for frontend work, so I cooked up this starter template to make life easier when building custom widgets.
I used SvelteKit because:
- It’s quick to set up.
- Routing just works—even inside an iframe, thanks to some dynamic base path logic in
src/routes/+layout.svelte
(shoutout to SvelteKit’s$app/paths
).
- Svelte 5 with SvelteKit
- TypeScript
- TailwindCSS (for quick styling)
- TagoIO SDK (via CDN)
- My bare hands (and presumably yours)
We use @sveltejs/adapter-static
and prerender
to generate static files. This makes the widget fully compatible with TagoIO’s hosting setup (which doesn’t do server-side rendering).
You can host the build anywhere (S3, Cloudfront, etc.), but uploading it directly to the TagoIO Files Manager is easiest—just note that you currently can’t upload entire folders at once.
-
Clone this repo:
git clone https://github.com/Ducktatorrr/sveltago
-
Install dependencies:
cd sveltago npm i
That’s it—you’re good to go.
Run a local dev server:
npm run dev
# Or open in a new tab:
npm run dev -- --open
In src/routes/+page.svelte
, there’s a check to see if you’re running locally. If so, it loads mock widget data that mimics what TagoIO sends. (You won’t see this data in production.)
Feel free to remove the sample src/routes/text
route and its references in +layout.svelte
if you don’t need it.
Build a production version:
npm run build
This creates a build/
folder full of static files. You can test it locally (without the mock data) by running:
npm run preview
There’s a current bug in TagoIO’s file upload API, so we can’t automate this just yet. Here’s the manual approach:
- In TagoIO’s Files Manager, create folders to mirror your build folder structure (like
_app/immutable/assets/
, etc.). - Upload the files from
build/
into each matching folder. Make sure they’re set to Public. - Grab the URL of
index.html
in your custom widget folder. - In your TagoIO dashboard, add a new widget and select Custom.
- Paste the URL and any parameters, select your device/variable, and create the widget.
- Enjoy your new Svelte-powered TagoIO custom widget!
Use the “Log widget data” and “Log real-time data” debug buttons in TagoIO to see what’s being passed into your widget.