You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support using Hilla endpoints from a service worker context to enable fetching data for offline support and background sync use cases.
Tier
Free
License
Apache 2.0
Motivation
Background
Vaadin current support of Service Workers is provided with the @PWA annotation. Using this annotation enables service worker Vite plugin and generates a template sw.ts that comes pre-configured for chaing the frontend resources of the application, including Hilla views, for offline support.
The service worker code can be optionally customized by developers for expanding its use beyond frontend resource caching, potentially also for storing data offline and syncing it on the background, without requiring the user to open or interact with the application.
Problem
Hilla endpoints do not work in when called from sw.ts or its imports due to limitations in Hilla:
Endpoints client does not compile in a service worker due to TypeScript errors for missing browser Window / DOM API. Thus the generated endpoints that involve the client are not importable.
HTTP requests do not pass the CSRF protection due to missing the token.
Thus it gets more difficult for developers to make server requests from a service worker compared with using Hilla endpoints from a regular browser tab context.
Solution
Remove the limitations that block using Hilla endpoints from a service worker context and make regular Hilla endpoints work same way as in the regular browser window script context.
Add documentation describing customizing the service worker and using Hilla endpoints in it.
Description
Support using Hilla endpoints from a service worker context to enable fetching data for offline support and background sync use cases.
Tier
Free
License
Apache 2.0
Motivation
Background
Vaadin current support of Service Workers is provided with the
@PWA
annotation. Using this annotation enables service worker Vite plugin and generates a templatesw.ts
that comes pre-configured for chaing the frontend resources of the application, including Hilla views, for offline support.The service worker code can be optionally customized by developers for expanding its use beyond frontend resource caching, potentially also for storing data offline and syncing it on the background, without requiring the user to open or interact with the application.
Problem
Hilla endpoints do not work in when called from
sw.ts
or its imports due to limitations in Hilla:Thus it gets more difficult for developers to make server requests from a service worker compared with using Hilla endpoints from a regular browser tab context.
Solution
Remove the limitations that block using Hilla endpoints from a service worker context and make regular Hilla endpoints work same way as in the regular browser window script context.
Add documentation describing customizing the service worker and using Hilla endpoints in it.
Notes
Epic issue: vaadin/hilla#2814
Requirements
Users can import Hilla endpoints from a customized
sw.ts
without errors.Calls to Hilla endpoints from a
sw.ts
work.Documentation
sw.ts
and example of using Hilla endpointsNice-to-haves
No response
Risks, limitations and breaking changes
Risks
Limitations
Breaking changes
Out of scope
Materials
No response
Metrics
No response
Pre-implementation checklist
Pre-release checklist
Security review
None
The text was updated successfully, but these errors were encountered: