The Agri-Tech Builder

Coding smart solutions for off-grid farming

Project Log: Building an Offline-First Freemium Wallet

Published: May 17, 2026

In my latest update for the Uni-Farm app, I tackled a major challenge for agricultural technology: monetization in areas with spotty internet. Today, I am breaking down how I built a freemium model that works completely offline.

The Connectivity Problem on Farms

Most freemium apps check a cloud database every time a user tries to perform an action to see if they have "credits" left. But out in the field, a farmer might not have a reliable 4G or 5G connection. If the app has to wait for a server response to scan a leaf, the app hangs and the user experience is ruined.

The Solution: A LocalStorage Wallet

Instead of relying on the cloud for every scan, I engineered an offline-first wallet utilizing the phone's native browser storage. Here is the core logic I used to check the user's scan limits instantly:

// Look in the phone's local storage for their wallet, or create a new one
let scanUsage = JSON.parse(localStorage.getItem('uniFarmScannerWallet')) || {
    freeScansUsed: 0,
    paidScansRemaining: 0
};

How the Logic Flows

When the user presses the scan button, the app checks the local uniFarmScannerWallet immediately—no internet required. It prioritizes paid scans first. If paidScansRemaining > 0, it deducts one and allows the scan. If they are out of paid scans, it checks if they have hit their limit of freeScansUsed.

This approach has two massive benefits:

  1. Lightning Fast UX: The app responds instantly in the field, even with zero bars of cell service.
  2. Reduced Server Costs: I am not pinging my backend database for read-requests on every single scan, saving me money on cloud operations.

By building offline-first, I am ensuring the app remains a reliable tool for farmers, regardless of where they are planted.