<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ramon Honório on Medium]]></title>
        <description><![CDATA[Stories by Ramon Honório on Medium]]></description>
        <link>https://medium.com/@ramonilho?source=rss-af9da6e2364b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WiwQhI1DswiIEI_JA7iiOQ.jpeg</url>
            <title>Stories by Ramon Honório on Medium</title>
            <link>https://medium.com/@ramonilho?source=rss-af9da6e2364b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 08:40:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ramonilho/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Server-Driven UI: the Ultimate Solution for Mobile Apps?]]></title>
            <link>https://medium.com/better-programming/server-driven-ui-does-it-solve-everything-for-mobile-apps-4b38397b2e04?source=rss-af9da6e2364b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b38397b2e04</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Ramon Honório]]></dc:creator>
            <pubDate>Wed, 01 Feb 2023 11:37:07 GMT</pubDate>
            <atom:updated>2023-02-27T06:19:38.432Z</atom:updated>
            <content:encoded><![CDATA[<h4>Exploring Server Driven UI in SwiftUI and Jetpack Compose</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-2BuwkqjJgMLCpMv" /><figcaption>Photo by <a href="https://unsplash.com/es/@javyrhodes?utm_source=medium&amp;utm_medium=referral">Javy Rhodes</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If you have already programmed a mobile application, you should already be familiar with the screen layout being created in a structure such as .xib, .storyboard, .xml files, or even in the Swift, Kotlin, Dart, or JavaScript code itself. We can create these screens statically, directly in the application bundle, but there are occasions where it is needed to retrieve the most updated information (e.g. catalog or history) or perform an action that requires validation (e.g. authentication or even purchasing that delivery snack) — in these cases, we have no choice but to rely on the backend.</p><p>The backend is the entire ecosystem that stores the data and provides the applications that contain the business rules that will be used by the clients — in our case, a mobile app. These apps, in turn, make requests to the <strong>server </strong>to retrieve data, format it, build the layout, and display it on a screen to the customers.</p><p>With Server-Driven UI (a.k.a Backend Driven UI), the game changes a little bit. The server not only returns the data but also returns <strong>how</strong> the screen will be built. Its composition, elements, components, and format, everything is defined.</p><p>But well… what is the benefit of it? Let’s check it out.</p><h3>Definition</h3><p>A way of visualizing it is imagining the components of your application (such as buttons, cards, or formatted texts) as LEGO blocks, while the server will provide the instruction manual for the app to build. There are several ways to create a Server-Driven UI, but the central idea is based on the following points:</p><ul><li>Service that is responsible for creating the screen structure, or instruction manual, with its respective configurations, data, and actions.</li><li>An app that performs the screen requests and is capable of assembling the components with the returned configurations.</li></ul><h4>Architecture</h4><p>Thinking of a microservices-oriented architecture, we can think of an example with only 3 main components, they are:</p><ul><li><strong>App</strong>: the application itself, its user interface. It can also be a mobile app or a web system, for example.</li><li><strong>Business Service</strong>: one or more services responsible for business rules, databases, states, experiments, etc.</li><li><strong>UI Service</strong>: the central orchestrator, responsible for retrieving business information from the Business Services and assembling the screen instruction manuals. You can also define this as being a UI-specialized BFF.</li></ul><p>The flow of opening a server-driven screen can be designed as something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5dZM8-IhOXUxCIJum7nxyA.png" /><figcaption>Flow diagram example with a high-level design of opening a screen with Server-Driven UI</figcaption></figure><p>Starting simple, let&#39;s think of a simple text component that will have its size configurable. Our UI Service should then return this component in an “instruction manual”, with a response like:</p><pre>{<br>  &quot;text&quot;: &quot;Hello, world!&quot;<br>  &quot;textSize&quot;: 12<br>}</pre><p>Where the content is in text and the font size setting is in textSize properties. Therefore, the respective apps must know how to configure the text component with this information. To achieve this, we created the ServerDrivenUIText, which is built based on a dictionary/map structure:</p><p><strong>iOS/SwiftUI</strong></p><pre>import SwiftUI<br>import Foundation<br><br>struct ServerDrivenUIText: View {<br>  @State var data: [String: Any] = [:]<br>  <br>  var body: some View {<br>    switch data.isEmpty {<br>    case true:<br>      ProgressView()<br>    case false:<br>      buildUI(fromData: data)<br>    }<br>  }<br>  <br>  func buildUI(fromData json: [String: Any]) -&gt; some View {<br>    guard let text = json[&quot;text&quot;] as? String, <br>          let textSize = json[&quot;textSize&quot;] as? CGFloat else {<br>      return Text(&quot;Error&quot;)<br>    }<br>    return Text(text)<br>      .font(.system(size: textSize))<br>  }<br>}</pre><p><strong>Android/Compose</strong></p><pre>import androidx.compose.foundation.Text<br>import androidx.compose.foundation.layout.Column<br>import androidx.compose.material.ProgressIndicator<br>import androidx.compose.runtime.Composable<br>import androidx.compose.runtime.mutableStateOf<br>import androidx.compose.ui.Modifier<br>import androidx.compose.ui.text.font.FontWeight<br>import androidx.compose.ui.unit.dp<br><br>@Composable<br>fun ServerDrivenUI() {<br>    val data = mutableStateOf(mapOf&lt;String, Any&gt;())<br>    when (data.value.isEmpty()) {<br>        true -&gt; ProgressIndicator(modifier = Modifier.padding(16.dp))<br>        false -&gt; buildUI(data = data.value)<br>    }<br>}<br>@Composable<br>fun buildUI(data: Map&lt;String, Any&gt;) {<br>    Column {<br>        val text = data[&quot;text&quot;] as? String ?: return@Column Text(&quot;Error&quot;, Modifier.padding(16.dp))<br>        val textSize = data[&quot;textSize&quot;] as? Int ?: 14<br>        Text(text, <br>            modifier = Modifier.padding(16.dp), <br>            fontSize = textSize.toDp())<br>    }<br>}</pre><p>Of course, loading a simple text could be even more simplified. But just having a setting like textSize already allows for changes to be made to the app layout without having to submit a new version to the stores, wait for approval, and rely on the user’s goodwill to update the app. This is potentially the biggest benefit of this architecture.</p><h4>So, is that it?</h4><p>Yes! In everyday life, we deal with screens much more complex than just a text component. That’s why it’s interesting to have a well-structured and configurable component library; mature enough to be able to build more complex components and even entire screens or flows.</p><p>With the components in the app well structured, if it’s necessary to implement, for example, an authentication initial screen, with Server-Driven we could receive something like:</p><pre>{<br>  &quot;name&quot;:&quot;Home Screen&quot;,<br>  &quot;elements&quot;:[<br>    {<br>      &quot;type&quot;:&quot;column&quot;,<br>      &quot;children&quot;:[<br>        {<br>          &quot;type&quot;:&quot;text&quot;,<br>          &quot;text&quot;:&quot;Welcome to the app!&quot;,<br>          &quot;fontSize&quot;:24,<br>          &quot;color&quot;:&quot;#000000&quot;<br>        },<br>        {<br>          &quot;type&quot;:&quot;text&quot;,<br>          &quot;text&quot;:&quot;Please log in to continue&quot;,<br>          &quot;fontSize&quot;:18,<br>          &quot;color&quot;:&quot;#777777&quot;<br>        },<br>        {<br>          &quot;type&quot;:&quot;row&quot;,<br>          &quot;children&quot;:[<br>            {<br>              &quot;type&quot;:&quot;button&quot;,<br>              &quot;text&quot;:&quot;Log in&quot;,<br>              &quot;backgroundColor&quot;:&quot;#4CAF50&quot;,<br>              &quot;color&quot;:&quot;#FFFFFF&quot;,<br>              &quot;onPress&quot;:&quot;loginFunction&quot;<br>            },<br>            {<br>              &quot;type&quot;:&quot;button&quot;,<br>              &quot;text&quot;:&quot;Sign up&quot;,<br>              &quot;backgroundColor&quot;:&quot;#3F51B5&quot;,<br>              &quot;color&quot;:&quot;#FFFFFF&quot;,<br>              &quot;onPress&quot;:&quot;signupFunction&quot;<br>            }<br>          ]<br>        }<br>      ]<br>    }<br>  ]<br>}</pre><p>And <em>voila</em>! There’s no need to submit a new version to the store to have the screen looking like this, with the defined configurations (font size, colors) and already being possible to run A/B testings (for instance: with the button&#39;s arrangement or different texts) without having to add a single line of code for feature flag in the application&#39;s bundle. And as this is all backend-processed, you can set the experimentation groups directly based on the user&#39;s request. Isn&#39;t it cool?</p><p><em>An extremely important gap you may be thinking of is: “Okay, my app can open, but how do I </em><strong><em>open</em></strong><em> this new screen since I need to add the code to push from one particular screen to another? Is there a way to open these screens dynamically too?” There is always a way, padawan, but that’s a topic for another article.</em></p><h3>Benefits</h3><p>When it comes to advantages and benefits, keep in mind that these vary depending on the problem you want to solve and/or the context in which it is being used. However, in general, some points that we can highlight are:</p><ul><li><strong>Fast updates and delivery</strong>: It is possible to make updates to the app without the need for the user to download and install a new version. This is really valuable when it comes to critical bug fixes or new functionalities. Normally, the app update process can take a while, as it depends on store review, phased rollout, and the user downloading the new version. This process can take weeks, while with Server-Driven it can happen in a single day.</li><li><strong>Enforce security</strong>: When using this approach, we allow the server to validate information before sending it to the mobile app, helping to ensure that data is reliable and protected against attacks. This is particularly relevant in apps that deal with sensitive data such as financial transactions or personal information. So if there’s a major security breach in a certain version, your server can detect the problematic version and block access, returning a customized experience.</li><li><strong>Experimentation friendly</strong>: It is possible to carry out A/B tests more easily and efficiently. This means that you can test different versions of the user interface with different user groups without having to update the mobile app with a feature flag. This is possible because the UI is loaded dynamically by the server.</li><li><strong>Personalization and accessibility</strong>: We can personalize the user interface for different user groups based on their needs, such as location, language, or device.</li><li><strong>Code reusability</strong>: By having a single “source of truth” for building a certain screen, the development process is only done once, and this code can already be distributed to multiple platforms.</li></ul><h3>Concerns</h3><p>Like any technology, Server-Driven UI is not a perfect approach. It is also important to consider the following concerns before taking the decision to implement in your application&#39;s ecosystem:</p><ul><li><strong>Latency and performance</strong>: As the mobile app needs to communicate with the server to get data and updates, there will be latency when displaying the user interface. This is because, in addition to the server response time, there&#39;s also processing and memory that you need to pay attention to. These concerns can cause problems in apps that require quick responses, such as games or messaging apps.</li><li><strong>Dependency on internet connection</strong>: As the mobile app needs to communicate with the server to get data and updates, it can only work when there is an established internet connection. This can be a problem in situations where the user has limited network coverage or it does not have internet access, or in applications designed with an offline-first architecture.</li><li><strong>Cost</strong>: Hosting and running a server-driven UI solution can become costly as it demands increased server resources and connectivity. Keep in mind that for every client opening a screen, we have at least one more request being made on the server.</li><li><strong>Complexity</strong>: Setting up and maintaining a server-driven UI infrastructure can be complex and requires specialized knowledge. You&#39;ll have an additional scope to create tooling, monitoring, and debugging. Another point to consider is that for every new component added in the UI lib that you want to use with Server-Driven, you may have to add the support on both fronts: the server side (defining the contract and populating with data) and the mobile side (parsing and creating the actual component).</li></ul><h3>So, is it the ultimate solution for mobile apps?</h3><p>No. The Server-Driven UI is an approach where the server is responsible for generating and sending the interface to the client, which can be a mobile or web application. And it is powerful because it can bring several benefits such as agility in updates and critical fixes, experimentation, and personalization; but there are also concerns such as latency and performance, internet connectivity dependency, and complexity.</p><p>But remember that there is no silver bullet and each methodology has its own trade-offs. It is important to assess the project, context, and business requirements before opting for any approach. Therefore, this one should totally be on your table when you’re designing a solution.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b38397b2e04" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/server-driven-ui-does-it-solve-everything-for-mobile-apps-4b38397b2e04">Server-Driven UI: the Ultimate Solution for Mobile Apps?</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>