Hi Siddharth,
When working on a hybrid mobile app in Mendix, choosing between microflows and nanoflows is critical for ensuring good performance, smooth user experience, and proper offline support. Both serve different purposes and should be used based on where and how the logic needs to run.
Nanoflows run on the client side (i.e., on the user’s device), making them ideal for quick, lightweight operations that don’t require a server or database interaction. Use nanoflows for things like updating UI elements, performing simple validations, showing or hiding containers, navigating between pages, or calling native device features like the camera, GPS, or barcode scanner. They are especially useful in offline scenarios, where the device may not have a network connection but still needs to function. Because they avoid the need to make a server call, nanoflows offer faster response times, enhancing the user experience.
Microflows, on the other hand, execute on the server and are designed for tasks that involve accessing or modifying persistent data, enforcing security rules, performing complex logic, or integrating with external systems like REST or SOAP services. Since they run on the server, microflows are required for creating, retrieving, updating, and deleting objects in the database, and for ensuring business logic is applied securely and consistently. However, they do require an internet connection and may introduce slight delays due to the round-trip between client and server.
In many cases, a hybrid approach is best: start with a nanoflow for immediate client-side response, and if server-side logic or data storage is needed, call a microflow from within the nanoflow. For example, when a user taps a "Save" button, a nanoflow can show a loading spinner and call a microflow to store the data securely, then return to the nanoflow to update the UI or show a success message.
To summarize, use nanoflows for fast, local, or offline-capable logic, and use microflows when you need to interact with the database, apply secure rules, or perform server-side tasks. Structuring your logic correctly between the two not only improves performance but also ensures your app behaves reliably in both online and offline conditions.