A PWA is nothing more than a Client. Clients and Servers have existed for decades, and often they share logic.
To handle shared logic the tried and tested methods are:
Literally share the logic as a library.
Duplicate the implementation, but have a single specification.
In short write ...