Image server for TRMNL built with Node.js, JSX and CSS
You can build a custom screen for Redirect or Alias plugins with your data and design.
As it bult on popular Javascript and Node.js platform, you can easily connect to database, fetch requests or get data from any source, and design it with HTML, JSX, CSS.
Quick Start
- Press button
Use this templateon Github or clone this repository - Example of JSX code already in repo and you can change it
- Create file .env.local based on .env.example
- You can preview result locally
npm run watch - After changes you should deploy your version of this repo to your server
Technologies used:
- Satori for rendering JSX to SVG
- resvg-js for rendering SVG to PNG
- Express.js as API server
- TSX for supporting JSX/TSX files
Endpoints of server
Image http://localhost:3000/image?secret_key=...
-- can be used for preview and Alias plugin
API http://localhost:3000/plugin/redirect?secret_key=...
-- can be used for Redirect plugin
JSX components
You can use regular JSX components (similar to React), but without hooks, as screen is rendering only once.
Starting point is App.tsx
It's easier to collect all variables and data in one place, before components. But you can
change to any structure that you prefer.
Layout design limitations
- Satori supports CSS Flexbox layout engine only
- it’s not a complete CSS standards implementation
- Each element (like
<div>) with a few child nodes should have explicit "display: flex"
Using fonts
To render screen you have to provide a font file. One is attached by default.
Including images
You can include local images by using LocalImage component or specify public url to somewhere.
Your Server (Production)
To run your TRMNL server you need any form of server (VM, droplet, pod, instance) somewhere, for example AWS, Google Cloud, Digital Ocean.
- it can be run via Dockerfile or command
npm run start - Better to pass ENV parameters from secure storage that your cloud provider has
Troubleshooting
Check log of errors on device:
https://usetrmnl.com/dashboard > top right dropdown > gear icon > scroll down to "Logs"
Fetch Screen Content as your device (Developer edition):
curl https://usetrmnl.com/api/display --header "access-token:xxxxxx"
Bring your own server (BYOS)
This repo implements basic BYOS server for one device.
You can setup it with those steps:
- Put your device's MAC value to ENV (can be .env.local). If you don't know it: just put anything and check server logs.
- Hold round button on your device for more than5 seconds - you should see connection instructions on screen.
- Connect your phone to wifi called
TRMNL - On setup choose
Custom server(see screenshot below) - Check logs of server
- If it still
wrong access-token value from device- you may need to chooseSoft reseton setup stage
Goal of this repo: simple and easy to customize.