Widgets (Win10+)

circle-exclamation

Windows Widgets allow your PWA to provide mini-applications displayed on the Windows widgets dashboard. Users can interact with your app content without opening the full application.

Overview

PWA Widgets use the Adaptive Cardsarrow-up-right template format to render content in the Windows widget panel. The bundle handles:

  • Manifest configuration: Declaring widgets in the Web App Manifest

  • Service worker integration: Automatic widget lifecycle management (install, update, uninstall)

  • Periodic updates: Background data refresh via Periodic Sync

Configuration

Widgets are configured in the manifest section:

config/packages/pwa.yaml
pwa:
    manifest:
        widgets:
            - name: "Weather Widget"
              short_name: "Weather"
              description: "Current weather conditions at a glance"
              tag: "weather"
              ms_ac_template: 'app_widget_weather_template'  # Symfony route name
              data: 'app_widget_weather_data'                 # Symfony route name
              type: "application/json"
              auth: false
              update: 3600          # Update every hour (in seconds)
              multiple: false       # Only one instance allowed
              screenshots:
                  - src: 'images/widget-weather.png'
                    label: 'Weather widget preview'
              icons:
                  - src: 'images/widget-weather-icon.svg'

Configuration Reference

Property
Type
Required
Description

name

string

Yes

Widget title displayed to users

description

string

Yes

Description of the widget

tag

string

Yes

Unique identifier for the widget

ms_ac_template

URL/route

Yes

URL or route name returning the Adaptive Cards template

data

URL/route

Yes

URL or route name returning widget data (JSON)

screenshots

array

Yes

At least one screenshot showing the widget

short_name

string

No

Shorter version of the widget name

type

string

No

MIME type for widget data (default: application/json)

auth

boolean

No

Whether the widget requires authentication

update

integer

No

Update frequency in seconds

multiple

boolean

No

Allow multiple widget instances (default: true)

icons

array

No

Widget-specific icons (falls back to manifest icons)

Server-Side Implementation

Adaptive Cards Template

Create a controller that returns an Adaptive Cards template:

How the Service Worker Works

The bundle automatically generates service worker code that:

  1. On widget install (widgetinstall event):

    • Fetches the Adaptive Cards template from ms_ac_template

    • Fetches data from the data URL

    • Renders the widget using self.widgets.updateByTag()

    • Registers periodic sync if update is configured

  2. On periodic sync (periodicsync event):

    • Refreshes the template and data

    • Updates the widget with fresh content

  3. On widget uninstall (widgetuninstall event):

    • Unregisters periodic sync when the last widget instance is removed

  4. On service worker activation:

    • Updates all registered widgets with fresh data

Multiple Widgets

You can configure multiple widgets:

Requirements and Limitations

  • Platform: Microsoft Edge on Windows 11+ only

  • Template format: Must use Adaptive Cardsarrow-up-right JSON format

  • Data format: Widget data endpoints must return valid JSON

  • URLs: Template and data URLs must be within the service worker scope

  • Update intervals: Subject to browser/OS scheduling policies (minimum interval may be enforced)

  • Icon size: Icons larger than 1024x1024 are ignored

Resources

Last updated

Was this helpful?