In the age of single-page apps (like Hashnode itself) and microservices, backend and frontend are usually totally decoupled.
And decoupled components should have well-defined interfaces - usually REST APIs.
When I have to share some logic between frontend and backend, I usually put it in a microservice so it can be used without any technology restrictions. It can be used from a native mobile app or a single-page app. It has a very low cost to replace any of these microservices.