Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: How to support both web and native mobile client?
2 points by _448 on Jan 10, 2022 | hide | past | favorite | 3 comments
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.




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


But for that the web client wii have to be an SPA? I want to create a simple old-fashioned(request-response/GET-POST type of server-side rendered) web app. Hence there is a common internal API, and the client facing interface is different for web app and native mobile app. For web app the response is the server-rendered web page, but for the mobile app the response is JSON.


no it does not, your php/node/perl/rails/whatever server-side rendering code can call exactly the same api as your native mobile app, assuming it runs on the same server, it could just call it at localhost/api/ instead of domain/api, or if the server can resolve the domain to a local address, even at domain/api




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: