A TypeScript library for interfacing with the Screenly Edge Apps API.
Important
This package requires Bun. The edge-apps-scripts CLI will not work with npm or node at this time.
bun add @screenly/edge-appsWhen developing Edge Apps locally using the library from this repository, you should link the package.
First, in the root of this repository:
bun linkThen in your Edge App directory:
cd /path/to/your-edge-app
bun link @screenly/edge-appsTo unlink the package when you're done with local development, run the following in your Edge App directory:
bun install --forceThen in the root of this repository:
bun unlinkimport { setupTheme, signalReady, getMetadata } from '@screenly/edge-apps'
setupTheme()
const metadata = getMetadata()
signalReady()setupTheme()- Apply theme colors to CSS custom propertiessetupBrandingLogo()- Fetch and process branding logosetupBranding()- Setup complete branding (colors and logo)
getSettings()- Get all settingsgetSetting<T>(key)- Get specific setting with type safetygetSettingWithDefault<T>(key, default)- Get setting with fallbacksignalReady()- Signal app is ready for display
getMetadata()- Get all screen metadatagetScreenName(),getHostname(),getLocation(),getScreenlyVersion(),getTags(),hasTag(tag),getFormattedCoordinates()getHardware()- Get hardware type asHardwareenum (Anywhere,RaspberryPi, orScreenlyPlayerMax)
getTimeZone()- Get timezone from GPS coordinatesgetLocale()- Get locale from locationformatCoordinates(coords)- Format coordinates as stringformatLocalizedDate(date, locale)- Format date for localeformatTime(date, locale, timezone)- Format time for localegetLocalizedDayNames(locale)- Get day names for localegetLocalizedMonthNames(locale)- Get month names for localedetectHourFormat(locale)- Detect 12h/24h format for locale
addUTMParams(url, params?)- Add UTM parameters to URLaddUTMParamsIf(url, enabled, params?)- Conditionally add UTM parameters
This package provides the edge-apps-scripts CLI tool for running shared development commands across all Edge Apps. It includes centralized ESLint configuration to avoid duplication.
Start the Vite development server with mock data from screenly.yml and mock-data.yml:
bun run devbun run buildTo lint your Edge App:
bun run lintTo lint and automatically fix issues:
bun run lint -- --fixRun TypeScript type checking:
bun run type-check- This library provides utilities to help with common Edge App tasks.
- The CLI uses the shared ESLint configuration from
@screenly/edge-apps, so you don't need to maintain your owneslint.config.ts - The build commands assume your Edge App has
index.htmlas the entry point - Build output will be generated in the
dist/directory
It is recommended to add the following scripts to your Edge App's package.json:
{
"scripts": {
"dev": "edge-apps-scripts dev",
"build": "edge-apps-scripts build",
"build:dev": "edge-apps-scripts build:dev",
"lint": "edge-apps-scripts lint",
"type-check": "edge-apps-scripts type-check",
"deploy": "bun run build && screenly edge-app deploy --path=dist/"
}
}Note
Feel free to customize the scripts as needed for your Edge App. You could also define your own configs like eslint.config.ts, tsconfig.json, or vite.config.ts if you need more control.
import { setupScreenlyMock, resetScreenlyMock } from '@screenly/edge-apps/test'
beforeEach(() => {
setupScreenlyMock({ screen_name: 'Test Screen' }, { theme: 'dark' })
})
afterEach(() => {
resetScreenlyMock()
})import type {
Hardware,
ScreenlyMetadata,
ScreenlySettings,
ScreenlyObject,
ThemeColors,
BrandingConfig,
UTMParams,
} from '@screenly/edge-apps'bun install # Install dependencies
bun test # Run tests
bun run build # Build library