HACKER Q&A
📣 _448

How to support both web and native mobile client?


I am trying to develop a simple web and mobile native app as a learning exercise. To support both web and native mobile app I am thinking of this broad backend architecture:

    DB <--> common internal api <-----> web request/response handler <---> web client
                             ^
                             |
                             +--------> REST API <----> native mobile app

My questions are:

0. Is this design to support both web clients and native mobile apps okay? Is there a better approach? I am trying to develop simple old-fashioned GET/POST and server-side rendered web app(i.e. not an SPA), but also want to support native mobile app.

1. When the browser sends a request to the backend, or receives a response from the backend, some of the important communication aspects such as TLS, cookie management, form data packing etc is handled by the browser on the client-side. How is this achieved on a native mobile app? Are there native libraries that handle this on behalf of the app? I do not want to use webview to wrap the web client on mobile devices.


  👤 dusted Accepted Answer ✓
I'd move it a bit around. And let both the native app and the web-renderer use the REST API and do away with the "internal" api.

DB <-> REST API <----> Native Mobile APP

           ^
           ---> Web Renderer <--> Browser