Can mobile applications use a serverless architecture?
Serverless architecture can be used for building mobile apps, in addition to web applications. Hybrid mobile apps with a serverless backend enable developers to incorporate the benefits of serverless computing while releasing apps that perform like native apps on almost any smartphone or tablet. Serverless mobile apps are able to scale quickly and easily as the user base grows.
What is a hybrid mobile app?
Hybrid mobile apps and native mobile apps are like two cars that look the same, have the same interior, and drive roughly the same, but have very different engines under the hood. A native app is built specifically for a certain kind of device and operating system, and its logic runs on the device itself.
Hybrid apps have become increasingly popular in recent years as concerns about performance have been addressed by technological improvements – for instance, Uber, Instagram, and Twitter are all hybrid apps. Developers sometimes prefer to use a hybrid architecture, as opposed to building native mobile applications, so that the application does not need to be rebuilt in multiple platform-specific languages for different devices. Unsurprisingly, building one app that works on multiple devices typically saves time in both in development and ongoing product support.
How does a mobile application with a serverless backend work?
With hybrid mobile apps, computing takes place in the cloud, not on the device. All cloud-hosted computing processes for the app can be serverless, just like a serverless web application; the only major difference between a serverless web app and a serverless hybrid mobile app is the native wrapper* on the frontend.
As with a serverless web application, the app code is hosted by a serverless vendor who handles all backend management. The application is divided up into smaller pieces called functions, and the functions do not live on any specific servers. Each function runs in response to triggering events, and the vendor's infrastructure starts up new instances of functions as needed. For example, if a user taps on a 'Purchase' button within an app with a serverless backend, this can trigger a backend function or series of functions that start up, record the transaction, and initiate delivery of whatever the user purchased.
What are the benefits of building a mobile app with a serverless backend?
Serverless mobile apps offer the same benefits as building a typical web application with a serverless backend:
- Scalability: Serverless apps are automatically scalable
- Less overhead: The vendor manages the entire backend
- Quick updates: Developers can update functions one at a time instead of updating an entire application at once, and there is no need to wait for users to install updates
- Pay-as-you-go: Developers only pay for the computing power the application uses, which can reduce ongoing costs
- Run code anywhere: The code can run on an edge network in order to reduce latency
*How does a native wrapper work?
Hybrid apps are able to function like native apps by leveraging the device's WebView. A WebView is a device-internal browser that displays the application as a browser would, while offering developers greater flexibility for customizing the appearance of their app than a regular browser. Additionally, most WebViews will enable the application to access hardware features on the device via an API.
For example, when a user opens Instagram, the app feels like a native app that's running on the device. But really, the device's WebView is rendering webpages generated by Instagram. The feed of images that users see when first opening up the app is a webpage, and all subsequent pages they visit are webpages, although they feel like they're part of a native application. Instagram is also able to access the device's camera and stored photos despite the fact that it is not a native app, and it can send push notifications.