<?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"><channel><title><![CDATA[Jamiu Okanlawon]]></title><description><![CDATA[Exploring the depths of full-stack Dart, Flutter internals, and the future of Generative AI. I build tools and share the journey to help developers master the Dart ecosystem.]]></description><link>https://developerjamiu.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Dec 2026 16:06:03 GMT</lastBuildDate><atom:link href="https://developerjamiu.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Deploy Your Dart Backend to Render]]></title><description><![CDATA[This guide picks up where Containerize Your Dart Backend with Docker left off. If you have not completed that guide yet, start there first. You should have…]]></description><link>https://developerjamiu.hashnode.dev/deploy-your-dart-backend-to-render</link><guid isPermaLink="true">https://developerjamiu.hashnode.dev/deploy-your-dart-backend-to-render</guid><dc:creator><![CDATA[Jamiu Okanlawon]]></dc:creator><pubDate>Thu, 05 Mar 2026 11:06:56 GMT</pubDate><content:encoded><![CDATA[<p>This guide picks up where <a href="https://developerjamiu.hashnode.dev/containerize-your-dart-backend-with-docker">Containerize Your Dart Backend with Docker</a> left off. If you have not completed that guide yet, start there first. You should have a working Dockerfile, a <code>.dockerignore</code> file, and a Docker image that runs successfully on your machine.</p>
<p>Now let's get it live on <a href="https://render.com/">Render</a>.</p>
<h2>What You Will Need</h2>
<ul>
<li><p>A containerized Dart backend project (completed the Docker guide above)</p>
</li>
<li><p>A <a href="https://github.com/">GitHub</a> account with your project pushed to a repository</p>
</li>
<li><p>A <a href="https://render.com/">Render</a> account (sign up with GitHub for the smoothest experience)</p>
</li>
</ul>
<h2>Why Render</h2>
<p>Render is a cloud platform that deploys your code from a GitHub repository. You push code. Render builds it, runs it, and gives you a URL. That is the core loop.</p>
<p>Here is why it works well for Dart developers specifically.</p>
<p><strong>Render builds Dockerfiles automatically.</strong> When Render detects a <code>Dockerfile</code> at the root of your repository, it uses that to build your project. Dart is not one of Render's natively supported languages, so the Dockerfile is how you tell Render exactly how to build and run your Dart application. This gives you full control over the build and runtime environments.</p>
<p><strong>Render provides a</strong> <code>PORT</code> <strong>environment variable.</strong> Render sets this to <code>10000</code> by default and passes it to your container as <code>PORT</code>. As long as your server reads from this variable (which you set up in the Docker guide), everything connects automatically.</p>
<p><strong>Automatic deploys from GitHub.</strong> Every push to your connected branch triggers a new deployment. Render builds the Docker image, starts the container, and routes traffic to it with zero downtime. If the build fails, your previous deployment stays live.</p>
<p><strong>Built-in environment variable management.</strong> API keys, database URLs, secrets. You configure them in Render's dashboard and they are injected into your container at runtime. No <code>.env</code> files in production.</p>
<p><strong>Predictable, instance-based pricing.</strong> Render charges a fixed monthly price per service instance. The Starter instance is $7/month and includes 512 MB RAM and 0.5 vCPU. You know your bill before the month ends. No surprise charges from traffic spikes.</p>
<h2>Render's Default Port: 10000</h2>
<p>One important difference between Render and other platforms: Render's default <code>PORT</code> is <code>10000</code>, not <code>8080</code>.</p>
<p>If your server reads the <code>PORT</code> environment variable (as covered in the Docker guide), this works automatically. You do not need to change your code. But you should update the <code>EXPOSE</code> instruction in your Dockerfile to match:</p>
<pre><code class="language-dockerfile">EXPOSE 10000
</code></pre>
<p>This is informational only and does not affect functionality, but it keeps your Dockerfile accurate and helps anyone reading it understand what port the container expects.</p>
<p>If you prefer to use a different port, you can override the default by setting the <code>PORT</code> environment variable in Render's dashboard.</p>
<h2>Deploying to Render</h2>
<h3>Step 1: Push Your Code to GitHub</h3>
<p>Make sure your repository includes:</p>
<ul>
<li><p>Your Dart source code</p>
</li>
<li><p><code>pubspec.yaml</code> and <code>pubspec.lock</code></p>
</li>
<li><p>The <code>Dockerfile</code> at the root of the repository</p>
</li>
<li><p>The <code>.dockerignore</code> file</p>
</li>
</ul>
<p>Commit and push:</p>
<pre><code class="language-bash">git add .
git commit -m "Add Dockerfile for Render deployment"
git push origin main
</code></pre>
<h3>Step 2: Create a Web Service</h3>
<ol>
<li><p>Go to <a href="https://render.com/">render.com</a> and log in.</p>
</li>
<li><p>In the Dashboard, click <strong>+ New</strong> in the top right corner, then select <strong>Web Service</strong>.</p>
</li>
<li><p>Connect your GitHub account if you have not already, then select your repository. Render walks you through a three-step flow: <strong>Choose service</strong>, <strong>Configure</strong>, and <strong>Deploy</strong>.</p>
</li>
<li><p>On the <strong>Configure</strong> step, Render detects your Dockerfile and pre-selects <strong>Docker</strong> as the Language. If it does not, set the <strong>Language</strong> dropdown to <strong>Docker</strong> manually.</p>
</li>
</ol>
<h3>Step 3: Configure the Service</h3>
<p>On the Configure page, fill in these details:</p>
<ul>
<li><p><strong>Name</strong>: Choose a name for your service (e.g., <code>my_shelf_app</code>). This becomes part of your <code>.onrender.com</code> URL.</p>
</li>
<li><p><strong>Branch</strong>: The Git branch to build and deploy. Defaults to <code>main</code>.</p>
</li>
<li><p><strong>Region</strong>: Pick the region closest to your users. Options include Oregon (US West), Ohio (US East), Virginia (US East), Frankfurt (EU), and Singapore (Asia).</p>
</li>
<li><p><strong>Root Directory</strong> (optional): Leave this blank unless your Dart project lives in a subdirectory of the repository (common with monorepos). If set, Render runs commands from this directory instead of the repository root.</p>
</li>
<li><p><strong>Instance Type</strong>: Select your instance type. The <strong>Free</strong> instance works for testing but spins down after 15 minutes of inactivity (more on this below). The <strong>Starter</strong> instance at $7/month stays always-on and is the minimum recommended for production.</p>
</li>
</ul>
<h3>Step 4: Add Environment Variables</h3>
<p>Below the Instance Type section on the same page, you will see the <strong>Environment Variables</strong> section. Add each key-value pair your application needs: database URLs, API keys, feature flags, and so on. You can also click <strong>Add from .env</strong> to upload variables from a local <code>.env</code> file, or click <strong>Generate</strong> next to a variable to let Render create a random secret value.</p>
<p>Render injects <code>PORT</code> automatically (defaulting to <code>10000</code>). You do not need to set it yourself unless your server requires a different port.</p>
<p>The <strong>Advanced</strong> section at the bottom contains additional options like health check paths, persistent disks, and Docker-specific settings. For a standard Dart backend, the defaults work fine.</p>
<h3>Step 5: Deploy</h3>
<p>Click <strong>Deploy Web Service</strong> at the bottom of the page. Render pulls your code, builds the Docker image, and starts the container.</p>
<p>You can watch the build and deploy progress in real time from the <strong>Events</strong> page. The first build takes longer because Docker has no cached layers yet. Subsequent deploys are faster thanks to Render's layer caching.</p>
<p>Once the deploy succeeds, Render assigns your service a public URL in the format <code>your-service-name.onrender.com</code>.</p>
<h3>Step 6: Verify the Deployment</h3>
<p>Open the generated URL in your browser or test it with <code>curl</code>:</p>
<pre><code class="language-bash">curl https://your-service-name.onrender.com
</code></pre>
<p>If everything is set up correctly, you will see a response from your Dart server.</p>
<h3>Step 7: Check the Logs</h3>
<p>If something goes wrong, the logs are your first stop.</p>
<ol>
<li><p>Navigate to your service in the Render Dashboard.</p>
</li>
<li><p>Click the <strong>Logs</strong> tab to see real-time output from your container.</p>
</li>
<li><p>For build issues, check the <strong>Events</strong> tab and click into the failed deploy to see the build log.</p>
</li>
</ol>
<p>If you see port binding errors, make sure your server reads the <code>PORT</code> environment variable. Render defaults to <code>10000</code> and can usually auto-detect a different port if your server binds to one, but relying on auto-detection is fragile. Reading <code>PORT</code> explicitly is the safest approach. Refer to the "Making Your Server Cloud-Ready" section in the <a href="https://developerjamiu.hashnode.dev/containerize-your-dart-backend-with-docker">Docker guide</a> if you need to revisit this.</p>
<h2>Adding a Custom Domain</h2>
<p>Render's generated <code>.onrender.com</code> domain works, but you probably want your own domain for production.</p>
<ol>
<li><p>In your service's dashboard, go to <strong>Settings</strong>.</p>
</li>
<li><p>Scroll to <strong>Custom Domains</strong> and click <strong>Add Custom Domain</strong>.</p>
</li>
<li><p>Enter your domain (e.g., <code>api.yourdomain.com</code>).</p>
</li>
<li><p>Render displays a CNAME target (or an A record for apex domains).</p>
</li>
<li><p>Go to your domain registrar and add the DNS record pointing to Render's target.</p>
</li>
<li><p>Wait for DNS propagation (usually a few minutes to a couple of hours).</p>
</li>
<li><p>Render automatically provisions a free TLS certificate once DNS resolves.</p>
</li>
</ol>
<p>If you are migrating from another platform, you likely have an existing DNS record pointing to that platform's domain. Update that record to point to Render's target instead.</p>
<h2>Automatic Deployments</h2>
<p>Every time you push to the connected branch (usually <code>main</code>), Render automatically builds and deploys the new version. This is enabled by default. You can configure which branch triggers deployments in the service settings.</p>
<p>The deployment process follows this sequence:</p>
<ol>
<li><p>Render detects the push to your repository.</p>
</li>
<li><p>It builds a new Docker image using your Dockerfile.</p>
</li>
<li><p>If the build succeeds, it starts a new container with the new image.</p>
</li>
<li><p>It routes traffic to the new container.</p>
</li>
<li><p>It stops the old container.</p>
</li>
</ol>
<p>If the build fails, the old deployment stays live. Your users are not affected by a broken push.</p>
<p>You can also configure Render to wait for CI checks to pass before deploying. Under your service's <strong>Settings</strong>, set auto-deploy behavior to <strong>After CI Checks Pass</strong>. This way, Render only deploys after your GitHub Actions (or other CI) succeed.</p>
<h2>Understanding Render Pricing</h2>
<p>Render uses an instance-based pricing model. You pick a service tier and pay a fixed monthly rate for that instance.</p>
<h3>Workspace Plans</h3>
<p>The <strong>Hobby</strong> plan is free and includes 100 GB of outbound bandwidth per month. It supports 1 project with 2 environments. Good for personal projects and small applications.</p>
<p>The <strong>Professional</strong> plan costs $19/user/month and includes 500 GB of bandwidth. It supports unlimited projects and environments, horizontal autoscaling, and preview environments.</p>
<h3>Compute Instances</h3>
<table>
<thead>
<tr>
<th>Instance</th>
<th>Price</th>
<th>RAM</th>
<th>vCPU</th>
</tr>
</thead>
<tbody><tr>
<td>Free</td>
<td>$0/month</td>
<td>512 MB</td>
<td>0.1</td>
</tr>
<tr>
<td>Starter</td>
<td>$7/month</td>
<td>512 MB</td>
<td>0.5</td>
</tr>
<tr>
<td>Standard</td>
<td>$25/month</td>
<td>2 GB</td>
<td>1</td>
</tr>
<tr>
<td>Pro</td>
<td>$85/month</td>
<td>4 GB</td>
<td>2</td>
</tr>
<tr>
<td>Pro Plus</td>
<td>$175/month</td>
<td>8 GB</td>
<td>4</td>
</tr>
</tbody></table>
<p>For most Dart backends, the <strong>Starter</strong> instance at $7/month is a solid starting point. Dart compiles to efficient native code and uses minimal memory at idle, so 512 MB goes a long way.</p>
<h3>Bandwidth</h3>
<p>Each workspace plan includes a monthly bandwidth allowance (100 GB for Hobby, 500 GB for Professional). Outbound bandwidth beyond the included amount is billed at $15 per 100 GB. This covers HTTP responses to clients and any outbound traffic your services initiate over the public internet.</p>
<h3>The Free Instance: What to Know</h3>
<p>The Free instance is useful for testing, demos, and personal experiments. But it comes with limitations:</p>
<ul>
<li><p><strong>Spins down after 15 minutes of inactivity.</strong> When no HTTP requests or WebSocket messages arrive for 15 minutes, Render shuts the container down. The next incoming request triggers a cold start that takes roughly 30 to 60 seconds. This makes the Free tier unsuitable for production APIs.</p>
</li>
<li><p><strong>No persistent disk.</strong> Any changes to the local filesystem (uploaded files, local SQLite databases) are lost on every redeploy, restart, or spin-down.</p>
</li>
<li><p><strong>No inbound private networking.</strong> Free services cannot receive traffic from other Render services over the private network. They can still send outbound requests to your data stores and paid services in the same region.</p>
</li>
<li><p><strong>750 instance hours per month.</strong> If your Free services exceed this, they are suspended until the next month.</p>
</li>
</ul>
<p>For anything beyond experimentation, the Starter instance at $7/month eliminates all of these constraints and keeps your service running continuously.</p>
<h2>What You Have Now</h2>
<p>At this point, your Dart backend is:</p>
<ul>
<li><p>Running on Render with a public URL</p>
</li>
<li><p>Automatically deploying on every push to GitHub</p>
</li>
<li><p>Protected by SSL with a valid TLS certificate</p>
</li>
<li><p>Reading environment variables securely from Render's dashboard</p>
</li>
<li><p>Packaged in a small, efficient Docker image built from a multi-stage Dockerfile</p>
</li>
</ul>
<p>You went from a containerized Dart project to a production deployment with continuous delivery. That is a solid foundation.</p>
<hr />
<p><em>Have questions or feedback? Find me on</em> <a href="https://x.com/developerjamiu"><em>Twitter</em></a><em>.</em></p>
]]></content:encoded></item><item><title><![CDATA[Deploy Your Dart Backend to Railway]]></title><description><![CDATA[This guide picks up where Containerize Your Dart Backend with Docker left off. If you have not completed that guide yet, start there first. You should have…]]></description><link>https://developerjamiu.hashnode.dev/deploy-your-dart-backend-to-railway</link><guid isPermaLink="true">https://developerjamiu.hashnode.dev/deploy-your-dart-backend-to-railway</guid><dc:creator><![CDATA[Jamiu Okanlawon]]></dc:creator><pubDate>Thu, 05 Mar 2026 10:58:17 GMT</pubDate><content:encoded><![CDATA[<p>This guide picks up where <a href="https://developerjamiu.hashnode.dev/containerize-your-dart-backend-with-docker">Containerize Your Dart Backend with Docker</a> left off. If you have not completed that guide yet, start there first. You should have a working Dockerfile, a <code>.dockerignore</code> file, and a Docker image that runs successfully on your machine.</p>
<p>Now let's get it live on <a href="https://railway.com/">Railway</a>.</p>
<h2>What You Will Need</h2>
<ul>
<li><p>A containerized Dart backend project (completed the Docker guide above)</p>
</li>
<li><p>A <a href="https://github.com/">GitHub</a> account with your project pushed to a repository</p>
</li>
<li><p>A <a href="https://railway.com/">Railway</a> account (sign up with GitHub for the smoothest experience)</p>
</li>
</ul>
<h2>Why Railway</h2>
<p>Railway is an infrastructure platform that deploys your code from a GitHub repository. You push code. Railway builds it, runs it, and gives you a URL. That is the core loop.</p>
<p>Here is why it works well for Dart developers specifically.</p>
<p><strong>Railway detects and uses Dockerfiles automatically.</strong> When Railway finds a <code>Dockerfile</code> at the root of your repository, it uses that to build your project. Dart is not one of Railway's auto-detected languages (like Node.js or Python), so the Dockerfile is how you tell Railway exactly how to build and run your Dart application. This is a good thing. It gives you full control.</p>
<p><strong>Railway injects a</strong> <code>PORT</code> <strong>environment variable.</strong> Railway assigns a dynamic port at runtime and passes it to your container as <code>PORT</code>. As long as your server reads from this variable (which you set up in the Docker guide), everything connects automatically.</p>
<p><strong>Automatic deploys from GitHub.</strong> Every push to your connected branch triggers a new deployment. Railway builds the Docker image, starts the container, and routes traffic to it. If the build fails, your previous deployment stays live.</p>
<p><strong>Built-in environment variable management.</strong> API keys, database URLs, secrets. You configure them in Railway's dashboard and they are injected into your container at runtime. No <code>.env</code> files in production.</p>
<p><strong>Usage-based pricing.</strong> Railway's Hobby plan costs \(5/month, which includes \)5 in usage credits. A typical Dart backend that handles moderate traffic stays well within that. You are billed per second for CPU and memory, so idle time costs almost nothing.</p>
<h2>Deploying to Railway</h2>
<h3>Step 1: Push Your Code to GitHub</h3>
<p>Make sure your repository includes:</p>
<ul>
<li><p>Your Dart source code</p>
</li>
<li><p><code>pubspec.yaml</code> and <code>pubspec.lock</code></p>
</li>
<li><p>The <code>Dockerfile</code> at the root of the repository</p>
</li>
<li><p>The <code>.dockerignore</code> file</p>
</li>
</ul>
<p>Commit and push:</p>
<pre><code class="language-bash">git add .
git commit -m "Add Dockerfile for Railway deployment"
git push origin main
</code></pre>
<h3>Step 2: Create a Railway Project</h3>
<ol>
<li><p>Go to <a href="https://railway.com/">railway.com</a> and log in with your GitHub account.</p>
</li>
<li><p>Click <strong>New Project</strong> in the top right corner of your dashboard.</p>
</li>
<li><p>Select <strong>GitHub Repository</strong> from the menu.</p>
</li>
<li><p>Find and select your repository from the list. If you do not see it, click <strong>Configure GitHub App</strong> to grant Railway access to the repository.</p>
</li>
<li><p>Railway detects the Dockerfile and starts building immediately.</p>
</li>
</ol>
<p>You will see the <strong>Architecture</strong> view, which is Railway's visual dashboard for your project. Your service tile will appear in the center showing a build in progress.</p>
<h3>Step 3: Add Environment Variables</h3>
<p>While the first build runs (or after it completes), add any environment variables your application needs.</p>
<ol>
<li><p>Click on your service tile (e.g., "my_shelf_app") on the Architecture view. A detail panel opens on the right.</p>
</li>
<li><p>Go to the <strong>Variables</strong> tab.</p>
</li>
<li><p>Click <strong>New Variable</strong> and add each key-value pair.</p>
</li>
</ol>
<p>Railway injects <code>PORT</code> automatically. You do not need to set it yourself. But add everything else your application depends on: database URLs, API keys, feature flags, and so on.</p>
<h3>Step 4: Generate a Public URL</h3>
<p>By default, Railway does not expose your service to the internet. You will see "Unexposed service" at the top of the detail panel. You need to generate a domain.</p>
<ol>
<li><p>Click on your service tile to open the detail panel.</p>
</li>
<li><p>Go to the <strong>Settings</strong> tab.</p>
</li>
<li><p>Under <strong>Networking</strong>, click <strong>Generate Domain</strong>.</p>
</li>
<li><p>Railway assigns a URL like <code>your-service-production.up.railway.app</code>.</p>
</li>
</ol>
<p>Your Dart backend is now live.</p>
<h3>Step 5: Verify the Deployment</h3>
<p>Open the generated URL in your browser or test it with <code>curl</code>:</p>
<pre><code class="language-bash">curl https://your-service-production.up.railway.app
</code></pre>
<p>If everything is set up correctly, you will see a response from your Dart server.</p>
<h3>Step 6: Check the Logs</h3>
<p>If something goes wrong, the logs are your first stop.</p>
<ol>
<li><p>Click on your service tile to open the detail panel.</p>
</li>
<li><p>In the <strong>Deployments</strong> tab, find the latest deployment.</p>
</li>
<li><p>Click <strong>View logs</strong> on the deployment entry to see both build and runtime output.</p>
</li>
</ol>
<p>If you see port binding errors, make sure your server reads the <code>PORT</code> environment variable. Railway assigns a dynamic port, so hardcoding a value will cause the health check to fail. Refer to the "Making Your Server Cloud-Ready" section in the <a href="https://developerjamiu.hashnode.dev/containerize-your-dart-backend-with-docker">Docker guide</a> if you need to revisit this.</p>
<h2>Adding a Custom Domain</h2>
<p>Railway's generated domain works, but you probably want your own domain for production.</p>
<ol>
<li><p>In your service settings, under <strong>Networking</strong>, click <strong>Custom Domain</strong>.</p>
</li>
<li><p>Enter your domain (e.g., <code>api.yourdomain.com</code>).</p>
</li>
<li><p>Railway provides a CNAME target.</p>
</li>
<li><p>Go to your domain registrar and add a CNAME record pointing to Railway's target.</p>
</li>
<li><p>Wait for DNS propagation (usually a few minutes to a couple of hours).</p>
</li>
<li><p>Railway automatically provisions an SSL certificate once DNS resolves.</p>
</li>
</ol>
<p>If you are migrating from another platform, you likely have an existing CNAME record pointing to that platform's domain. Update that record to point to Railway's target instead.</p>
<h2>Automatic Deployments</h2>
<p>Every time you push to the connected branch (usually <code>main</code>), Railway automatically builds and deploys the new version. This is enabled by default. You can configure which branch triggers deployments in the service settings.</p>
<p>The deployment process follows this sequence:</p>
<ol>
<li><p>Railway detects the push to your repository.</p>
</li>
<li><p>It builds a new Docker image using your Dockerfile.</p>
</li>
<li><p>If the build succeeds, it starts a new container with the new image.</p>
</li>
<li><p>It routes traffic to the new container.</p>
</li>
<li><p>It stops the old container.</p>
</li>
</ol>
<p>If the build fails, the old deployment stays live. Your users are not affected by a broken push.</p>
<h2>Understanding Railway Pricing</h2>
<p>Railway uses a subscription-plus-usage model.</p>
<p>The <strong>Free plan</strong> costs \(0/month and includes a one-time \)5 credit with a 30-day trial. After the trial, it continues at $1/month with limited resources (1 vCPU, 0.5 GB RAM per service). Good for testing and small apps.</p>
<p>The <strong>Hobby plan</strong> costs \(5/month and includes \)5 in usage credits. If your usage stays under \(5, you only pay the \)5 subscription. If your usage goes to \(8, you pay \)8 total. Most Dart backends serving moderate traffic stay well within the included credits.</p>
<p>Usage is calculated per second based on:</p>
<ul>
<li><p><strong>CPU</strong>: \(0.00000772/second per vCPU (~\)20/vCPU/month)</p>
</li>
<li><p><strong>Memory</strong>: \(0.00000386/second per GB (~\)10/GB/month)</p>
</li>
<li><p><strong>Egress</strong>: $0.05 per GB of outbound data</p>
</li>
</ul>
<p>A Dart compiled binary is lean. It uses minimal memory at idle and handles requests efficiently. This is one of Dart's strengths on a usage-based platform: you are not paying for a heavyweight runtime sitting idle.</p>
<h2>What You Have Now</h2>
<p>At this point, your Dart backend is:</p>
<ul>
<li><p>Running on Railway with a public URL</p>
</li>
<li><p>Automatically deploying on every push to GitHub</p>
</li>
<li><p>Protected by SSL with a valid certificate</p>
</li>
<li><p>Reading environment variables securely from Railway's dashboard</p>
</li>
<li><p>Packaged in a small, efficient Docker image built from a multi-stage Dockerfile</p>
</li>
</ul>
<p>You went from a containerized Dart project to a production deployment with continuous delivery. That is a solid foundation.</p>
<hr />
<p><em>Have questions or feedback? Find me on</em> <a href="https://x.com/developerjamiu"><em>Twitter</em></a><em>.</em></p>
]]></content:encoded></item><item><title><![CDATA[Containerize Your Dart Backend with Docker]]></title><description><![CDATA[Your Dart backend works on your machine. Before it can work anywhere else, it needs to be packaged in a way that runs identically on any server in the…]]></description><link>https://developerjamiu.hashnode.dev/containerize-your-dart-backend-with-docker</link><guid isPermaLink="true">https://developerjamiu.hashnode.dev/containerize-your-dart-backend-with-docker</guid><dc:creator><![CDATA[Jamiu Okanlawon]]></dc:creator><pubDate>Thu, 05 Mar 2026 10:57:44 GMT</pubDate><content:encoded><![CDATA[<p>Your Dart backend works on your machine. Before it can work anywhere else, it needs to be packaged in a way that runs identically on any server in the world. That is what <a href="https://www.docker.com/">Docker</a> does.</p>
<p>This guide walks you through containerizing a Dart backend project, from writing your first Dockerfile to testing the image locally. Once you complete this guide, your project will be ready to deploy on any platform that supports Docker containers: <a href="https://railway.com/">Railway</a>, <a href="https://render.com/">Render</a>, <a href="http://Fly.io">Fly.io</a>, Google Cloud Run, or anywhere else.</p>
<h2>What You Will Need</h2>
<p>Before we start, make sure you have:</p>
<ul>
<li><p>A Dart backend project that runs locally (Shelf, Dart Frog, Serinus, or any Dart HTTP server)</p>
</li>
<li><p><a href="https://docs.docker.com/get-docker/">Docker</a> installed on your machine</p>
</li>
<li><p>The <a href="https://dart.dev/get-dart">Dart SDK</a> installed locally</p>
</li>
</ul>
<h2>Why Docker</h2>
<p>Dart compiles to native machine code ahead of time. The resulting binary is fast, lightweight, and needs only a minimal runtime to execute. But here is the catch: a binary compiled on macOS will not run on Linux. A binary compiled on one Linux distribution might not run on another if the system libraries do not match.</p>
<p>Docker solves this. You compile inside a Linux container, and then you run inside a compatible Linux container. The build environment and the runtime environment are both defined in your <code>Dockerfile</code>, so there are no surprises.</p>
<h3>Multi-Stage Builds</h3>
<p>The Dockerfile we are going to write uses a technique called a <strong>multi-stage build</strong>. The idea is simple: one stage installs the Dart SDK and compiles your code, then a second stage starts from <code>scratch</code> (a completely empty base image) and takes only the compiled output and the minimal Dart runtime. No SDK, no source code, no <code>pub</code> cache, no operating system layer in your final image.</p>
<p>The result is a production image that can be as small as ~10 MB, ships no build tools or source code, and deploys faster because there is less to transfer.</p>
<h2>Writing the Dockerfile</h2>
<p>Create a file named <code>Dockerfile</code> (no extension) at the root of your project. Let's build it step by step. I will explain every line so you understand what it does and why it is there.</p>
<h3>The Build Stage</h3>
<pre><code class="language-dockerfile">FROM dart:stable AS build
</code></pre>
<p>This pulls the official Dart Docker image tagged <code>stable</code>. It includes the full Dart SDK: the compiler, the <code>pub</code> package manager, and the Dart VM. The <code>AS build</code> part names this stage so we can reference it later.</p>
<p><strong>Note:</strong> You can also pin a specific Dart SDK version instead of <code>stable</code>. For example, <code>FROM dart:3.11.0 AS build</code> locks the build to Dart 3.11.0 regardless of what <code>stable</code> resolves to in the future. This is useful if you want reproducible builds and want to avoid surprises when the stable channel updates.</p>
<pre><code class="language-dockerfile">WORKDIR /app
</code></pre>
<p>Sets the working directory inside the container. All subsequent commands run from <code>/app</code>.</p>
<pre><code class="language-dockerfile">COPY pubspec.* ./
RUN dart pub get
</code></pre>
<p>This copies only your <code>pubspec.yaml</code> and <code>pubspec.lock</code> files first, then resolves dependencies. Why not copy everything at once? Docker caches each layer. If your source code changes but your dependencies do not, Docker reuses the cached dependency layer and skips <code>dart pub get</code> entirely. This makes rebuilds significantly faster.</p>
<pre><code class="language-dockerfile">COPY . .
</code></pre>
<p>Now copy the rest of your project source code. At this point, dependencies are already resolved, so this step is fast.</p>
<pre><code class="language-dockerfile">RUN dart build cli --target bin/server.dart -o output
</code></pre>
<p>This is the key step. <code>dart build cli</code> performs the AOT compilation. This command was introduced in Dart 3.10 and is the recommended way to build Dart server applications. It compiles your code into a native binary and bundles it with the minimal runtime dependencies your app needs. The <code>--target</code> flag specifies your entry point, and <code>-o</code> specifies the output directory. The compiled output lands in <code>output/bundle/</code>.</p>
<p>Replace <code>bin/server.dart</code> with your actual entry point. More on framework-specific entry points below.</p>
<h3>The Runtime Stage</h3>
<pre><code class="language-dockerfile">FROM scratch
</code></pre>
<p>This starts a new, completely empty stage. Unlike Alpine or Debian, <code>scratch</code> contains nothing at all: no OS, no shell, no package manager. The only things in the final image will be what we explicitly copy in.</p>
<pre><code class="language-dockerfile">COPY --from=build /runtime/ /
</code></pre>
<p>The official <code>dart:stable</code> Docker image includes a <code>/runtime/</code> directory containing the minimal system libraries and configuration files needed to run an AOT-compiled Dart binary. This single line copies that runtime foundation into our empty image. No need to install <code>libc6-compat</code> or any other packages manually.</p>
<pre><code class="language-dockerfile">COPY --from=build /app/output/bundle/ /app/
</code></pre>
<p>This copies the compiled application bundle from the build stage. The <code>dart build cli</code> command organizes its output into a <code>bundle/</code> directory that contains the compiled binary and any runtime assets it depends on.</p>
<pre><code class="language-dockerfile">EXPOSE 8080
</code></pre>
<p>Documents that the container listens on port 8080. This is informational for humans and tools. Most cloud platforms override this with a <code>PORT</code> environment variable, but it is good practice to include it. Some platforms (like Render) use a different default port. You will adjust this value in the platform-specific deployment guide.</p>
<pre><code class="language-dockerfile">CMD ["/app/bin/server"]
</code></pre>
<p>The command that runs when the container starts. This launches your compiled Dart server from the bundle output.</p>
<h3>The Complete Dockerfile</h3>
<p>Here is the full Dockerfile, ready to copy:</p>
<pre><code class="language-dockerfile"># Stage 1: Build the Dart application
FROM dart:stable AS build

WORKDIR /app

# Resolve dependencies first (cached layer)
COPY pubspec.* ./
RUN dart pub get

# Copy source code and compile
COPY . .
RUN dart build cli --target bin/server.dart -o output

# Stage 2: Create a minimal runtime image
FROM scratch

COPY --from=build /runtime/ /
COPY --from=build /app/output/bundle/ /app/

EXPOSE 8080

CMD ["/app/bin/server"]
</code></pre>
<h2>Framework-Specific Entry Points</h2>
<p>The Dockerfile above works for any Dart backend, but each framework has a slightly different entry point. Here is what to change.</p>
<h3>Shelf</h3>
<p>New Shelf projects generated by <code>dart create -t server-shelf</code> use <code>bin/server.dart</code> as the entry point. No changes needed. If your project uses a different file name (like <code>bin/main.dart</code>), update the <code>--target</code> flag accordingly.</p>
<h3>Serinus</h3>
<p>The entry point is <code>bin/&lt;project_name&gt;.dart</code> (e.g., <code>bin/my_serinus_app.dart</code>). You need to update both the <code>--target</code> flag and the <code>CMD</code> to match your project name:</p>
<pre><code class="language-dockerfile">RUN dart build cli --target bin/my_serinus_app.dart -o output
</code></pre>
<p>And in the runtime stage:</p>
<pre><code class="language-dockerfile">CMD ["/app/bin/my_serinus_app"]
</code></pre>
<h3>Dart Frog: A Special Case</h3>
<p>Dart Frog generates server code from your route definitions. You need to run the Dart Frog build step before compiling. Here is the adjusted Dockerfile:</p>
<pre><code class="language-dockerfile">FROM dart:stable AS build

WORKDIR /app

# Copy the entire project (Dart Frog needs the full directory structure for code generation)
COPY . .

# Install the Dart Frog CLI and add it to PATH
RUN dart pub global activate dart_frog_cli
ENV PATH="/root/.pub-cache/bin:${PATH}"

# Resolve dependencies
RUN dart pub get

# Generate the server code from your route definitions
RUN dart_frog build

# Compile the generated server
RUN dart build cli --target build/bin/server.dart -o output

FROM scratch
COPY --from=build /runtime/ /
COPY --from=build /app/output/bundle/ /app/
EXPOSE 8080
CMD ["/app/bin/server"]
</code></pre>
<p>Notice that we copy everything before resolving dependencies because Dart Frog's code generation needs access to your route files, middleware, and directory layout. With Shelf, we can copy just <code>pubspec.*</code> first and cache the dependency layer separately. With Dart Frog, almost any code change triggers code generation, which invalidates that cache anyway. The trade-off is acceptable.</p>
<h2>Using Dart Versions Before 3.10</h2>
<p>The <code>dart build cli</code> command was introduced in Dart 3.10 alongside build hooks. If your project uses an older Dart SDK version, use <code>dart compile exe</code> instead. Here is the equivalent Dockerfile pinned to Dart 3.9:</p>
<pre><code class="language-dockerfile"># Stage 1: Build the Dart application
FROM dart:3.9 AS build

WORKDIR /app

# Resolve dependencies first (cached layer)
COPY pubspec.* ./
RUN dart pub get

# Copy source code and compile
COPY . .
RUN dart compile exe bin/server.dart -o bin/server

# Stage 2: Create a minimal runtime image
FROM scratch

COPY --from=build /runtime/ /
COPY --from=build /app/bin/server /app/bin/server

EXPOSE 8080

CMD ["/app/bin/server"]
</code></pre>
<p>The key differences: <code>dart compile exe</code> produces a single standalone binary instead of a bundle directory, and you copy that binary directly. The <code>/runtime/</code> directory is available in all recent versions of the official Dart Docker image, so <code>FROM scratch</code> works with both approaches.</p>
<h2>Making Your Server Cloud-Ready</h2>
<p>Before deploying to any platform, your Dart server needs two things to work in a containerized environment.</p>
<h3>1. Listen on the PORT Environment Variable</h3>
<p>Every major cloud platform assigns a port and passes it as the <code>PORT</code> environment variable. Your server must read it.</p>
<p><strong>Shelf:</strong></p>
<p>New Shelf projects generated by <code>dart create -t server-shelf</code> read the <code>PORT</code> environment variable by default. The example below shows what that looks like in practice. If you have customized your entry point, verify that it still reads from <code>Platform.environment['PORT']</code>.</p>
<pre><code class="language-dart">import 'dart:io';
import 'package:shelf/shelf.dart';
import 'package:shelf/shelf_io.dart' as shelf_io;

void main() async {
  final port = int.parse(Platform.environment['PORT'] ?? '8080');

  final handler = const Pipeline()
      .addMiddleware(logRequests())
      .addHandler(_router);

  final server = await shelf_io.serve(handler, InternetAddress.anyIPv4, port);
  print('Serving at http://\({server.address.host}:\){server.port}');
}
</code></pre>
<p><strong>Dart Frog:</strong></p>
<p>Dart Frog reads the <code>PORT</code> environment variable by default. You do not need to change anything. If you have customized the entry point, verify that it respects the <code>PORT</code> variable.</p>
<p><strong>Serinus:</strong></p>
<p>Serinus reads the <code>PORT</code> environment variable automatically. The default project template also sets the host to <code>'0.0.0.0'</code>. You do not need to change anything. If you have customized the <code>host</code> parameter in your <code>bootstrap()</code> function, make sure it is still set to <code>'0.0.0.0'</code> and not <code>'localhost'</code>.</p>
<h3>2. Bind to All Network Interfaces</h3>
<p>As shown in the Shelf example above, your server must bind to <code>InternetAddress.anyIPv4</code> (which resolves to <code>0.0.0.0</code>), not <code>localhost</code> or <code>127.0.0.1</code>. Binding to localhost only accepts connections from inside the container. Cloud platforms route external traffic to the container's network interface, so the server needs to accept connections on all IPv4 interfaces.</p>
<h2>Adding a .dockerignore File</h2>
<p>Create a <code>.dockerignore</code> file at the root of your project. This tells Docker which files to skip when copying your project into the build context. Smaller build context means faster builds.</p>
<pre><code class="language-plaintext">.dockerignore
Dockerfile
build/
.dart_tool/
.git/
.github/
.gitignore
.idea/
.packages
</code></pre>
<p>This excludes the Dart tool cache, Git history, build artifacts, and IDE configuration files. None of these are needed inside the Docker image.</p>
<p>The <code>.dart_tool/</code> entry is especially important. If this directory is copied into the container, <code>dart pub get</code> may retain local-machine paths (like <code>/Users/yourname/.pub-cache/...</code>) that do not exist inside the Docker build. This causes "No such file or directory" errors during compilation. Excluding <code>.dart_tool/</code> forces Docker to generate fresh paths.</p>
<h2>Testing Locally</h2>
<p>Before pushing to any platform, verify that your Docker image builds and runs correctly on your machine.</p>
<p>Build the image:</p>
<pre><code class="language-bash">docker build -t my-dart-backend .
</code></pre>
<p>Run the container:</p>
<pre><code class="language-bash">docker run -it -p 8080:8080 my-dart-backend
</code></pre>
<p>Test it:</p>
<pre><code class="language-bash">curl http://localhost:8080
</code></pre>
<p>If you get a response, your Dockerfile is working. If you get a connection error, check that your server binds to <code>0.0.0.0</code> and listens on the <code>PORT</code> environment variable.</p>
<h2>Fixing Common Docker Issues</h2>
<p><strong>"No such file or directory" for package imports</strong>: Your <code>.dart_tool/</code> directory was copied into the container with paths from your local machine. Make sure <code>.dart_tool/</code> is listed in your <code>.dockerignore</code> file so Docker skips it and <code>dart pub get</code> generates fresh paths inside the container.</p>
<p><strong>"exec format error"</strong>: Your binary was compiled for the wrong architecture. Make sure you are using <code>dart:stable</code> as the build image, not compiling locally and copying the binary in.</p>
<p><strong>Missing runtime libraries</strong>: If you are using <code>FROM scratch</code>, make sure you are copying <code>/runtime/</code> from the build stage. This directory contains the system libraries your Dart binary needs. Without it, the binary will fail silently or crash on startup.</p>
<p><strong>Port binding errors</strong>: If your server hardcodes a port instead of reading the <code>PORT</code> environment variable, it will work locally but fail when deployed to a platform that injects a different port.</p>
<p><strong>Build timeout</strong>: If your project has many dependencies, the first build might take a while. Subsequent builds use cached layers and are faster.</p>
<p><strong>"dart build" not found</strong>: You are using a Dart SDK version older than 3.10. Either update your Dart SDK version or switch to the legacy Dockerfile that uses <code>dart compile exe</code> (see the "Using Dart Versions Before 3.10" section).</p>
<h2>What You Have Now</h2>
<p>At this point, your Dart backend is:</p>
<ul>
<li><p>Packaged in a small, efficient Docker image built from a multi-stage Dockerfile</p>
</li>
<li><p>Reading the <code>PORT</code> environment variable so it works on any cloud platform</p>
</li>
<li><p>Binding to all network interfaces so cloud load balancers can route traffic to it</p>
</li>
<li><p>Tested locally and ready to deploy</p>
</li>
</ul>
<p>The next step is to push this container to a cloud platform. Pick the guide for your platform of choice:</p>
<ul>
<li><p><a href="https://developerjamiu.hashnode.dev/deploy-your-dart-backend-to-railway">Deploy to Railway</a></p>
</li>
<li><p><a href="https://developerjamiu.hashnode.dev/deploy-your-dart-backend-to-render">Deploy to Render</a></p>
</li>
</ul>
<hr />
<p><em>Have questions or feedback? Find me on</em> <a href="https://x.com/developerjamiu"><em>Twitter</em></a><em>.</em></p>
]]></content:encoded></item><item><title><![CDATA[How Apps Change Without Updates: A Developer's Guide to Flavors, Feature Flags, and OTA]]></title><description><![CDATA[Confused by how apps like WhatsApp update without the App Store? This guide clearly explains the differences between Flavors, Feature Flags and OTAs.]]></description><link>https://developerjamiu.hashnode.dev/how-apps-change-without-updates</link><guid isPermaLink="true">https://developerjamiu.hashnode.dev/how-apps-change-without-updates</guid><category><![CDATA[OTAUpdates]]></category><category><![CDATA[  feature flags]]></category><category><![CDATA[flavors]]></category><category><![CDATA[Flutter]]></category><category><![CDATA[React Native]]></category><dc:creator><![CDATA[Jamiu Okanlawon]]></dc:creator><pubDate>Sun, 09 Nov 2025 07:46:53 GMT</pubDate><content:encoded><![CDATA[<p>Ever opened an app like WhatsApp and suddenly seen a new feature, like Channels or a new UI for attachments? You check the App Store, but you don't remember updating the app. How is this possible?</p>
<p>As developers, we know it's not magic. But this common "magic" is often a source of confusion. Friends and colleagues mix up three related but distinct concepts: <strong>Flavors</strong>, <strong>Feature Flags</strong>, and <strong>Over-The-Air (OTA) Updates</strong>.</p>
<p>They all relate to shipping different versions of your app, but they solve completely different problems at different stages of the development lifecycle.</p>
<p>Let's demystify them for good.</p>
<h2 id="heading-1-flavors-the-build-time-recipe">1. Flavors (The Build-Time Recipe)</h2>
<p>This is the concept you work with <em>before</em> you even build your app.</p>
<p><strong>What They Are:</strong> Flavors (called <em>Build Variants</em> on Android or <em>Schemes</em> on iOS) are a <strong>build-time configuration</strong>. They allow you to produce different versions of your app from the exact same source code. You define a set of "recipes" in your build configuration (like <code>build.gradle</code> or Xcode's project settings).</p>
<p><strong>Analogy:</strong> You have one batch of cookie dough (your codebase). Flavors are the different recipes you use at baking time. One recipe adds chocolate chips (your "Pro" flavor), one adds nuts (your "Client A" white-label), and one is plain (your "Free" flavor).</p>
<p><strong>Why We Need Them:</strong></p>
<ul>
<li><p><strong>Environments:</strong> This is the most common use. You create a <code>development</code> flavor that points to <a target="_blank" href="http://dev-api.myapp.com"><code>dev-api.myapp.com</code></a>, a <code>staging</code> flavor that points to <a target="_blank" href="http://staging-api.myapp.com"><code>staging-api.myapp.com</code></a>, and a <code>production</code> flavor that points to the live <a target="_blank" href="http://api.myapp.com"><code>api.myapp.com</code></a>.</p>
</li>
<li><p><strong>White-Labeling:</strong> You have a single app codebase but sell it to multiple clients. Flavors let you create <code>client_a_app</code> and <code>client_b_app</code>, each with a different name, logo, color theme, and bundle ID, all from the same code.</p>
</li>
<li><p><strong>Free vs. Pro:</strong> You can compile a "Free" version with certain features disabled at compile time and a "Pro" version with them all enabled.</p>
</li>
</ul>
<blockquote>
<p><strong>Key Takeaway:</strong> A Flavor is decided <strong>at compile time</strong>. The user downloads <em>one specific flavor</em> (e.g., the "production" app) and cannot be changed unless they download a <em>different</em> app file (.apk or .ipa).</p>
</blockquote>
<h2 id="heading-2-feature-flags-the-remote-switch">2. Feature Flags (The Remote Switch)</h2>
<p>This is the technique that answers the "WhatsApp magic" question.</p>
<p><strong>What They Are:</strong> A Feature Flag (or Feature Toggle) is a <strong>runtime conditional check</strong> in your code that is controlled by a remote server. It's essentially a powerful <code>if</code> statement.</p>
<pre><code class="lang-dart"><span class="hljs-comment">// Example in Flutter/Dart</span>
<span class="hljs-keyword">if</span> (featureFlags.isNewChatUIEnabled()) {
  <span class="hljs-comment">// Show the new UI</span>
  <span class="hljs-keyword">return</span> NewChatScreen();
} <span class="hljs-keyword">else</span> {
  <span class="hljs-comment">// Show the old, stable UI</span>
  <span class="hljs-keyword">return</span> OldChatScreen();
}
</code></pre>
<p><strong>Analogy:</strong> You've already installed a new, high-tech light bulb in your room (the code is already in the app). The feature flag is the <strong>remote control switch</strong> on your wall (or on a server). You can turn the light on (enable the feature) for <em>everyone</em>, for just <em>some</em> people, or turn it off if it's flickering (a bug).</p>
<p><strong>Why We Need Them:</strong></p>
<ul>
<li><p><strong>Gradual Rollouts:</strong> This is the big one. Instead of releasing a new feature to 100% of your users and <em>hoping</em> it doesn't crash, you can release it to 1%, then 5%, then 20%, monitoring for errors.</p>
</li>
<li><p><strong>A/B Testing:</strong> Show 50% of users <code>Button A</code> and 50% <code>Button B</code> to see which one performs better.</p>
</li>
<li><p><strong>Kill Switch:</strong> If you roll out a new feature and discover it has a critical bug, you can remotely "flip the switch" to turn it off for all users <em>instantly</em>, without needing a new app store release.</p>
</li>
<li><p><strong>Targeted Releases:</strong> Enable a feature only for your "Beta Testers" group, or only for users in a specific country.</p>
</li>
</ul>
<p><strong>Popular Tools for Feature Flags:</strong></p>
<ul>
<li><p><a target="_blank" href="https://firebase.google.com/docs/remote-config">Firebase Remote Config</a>: A free starting point, especially if you're already in the Firebase ecosystem.</p>
</li>
<li><p><a target="_blank" href="https://launchdarkly.com/">LaunchDarkly</a>": An enterprise-grade, platform focused purely on feature management and experimentation.</p>
</li>
<li><p><a target="_blank" href="https://www.flagsmith.com/"><strong>Flagsmith</strong></a><strong>:</strong> An open-source option, allowing you to self-host for complete data control.</p>
</li>
</ul>
<blockquote>
<p><strong>Key Takeaway:</strong> The code for <strong>both</strong> the old and new feature <em>must</em> already be on the user's device. The feature flag is just a remote boolean (true/false) that tells the app which code path to execute.</p>
</blockquote>
<h2 id="heading-3-over-the-air-ota-updates-the-hotfix">3. Over-The-Air (OTA) Updates (The Hotfix)</h2>
<p>This is the one that <em>actually</em> sends new code to the app, bypassing the app store.</p>
<p><strong>What They Are:</strong> OTA updates are a mechanism to push <strong>new code and assets</strong> (like new Dart code, JS bundles, or images) directly to a user's app <em>after</em> it has been installed. This <em>bypasses</em> the normal <strong>App Store</strong> or <strong>Play Store</strong> review and update process.</p>
<p><strong>Analogy:</strong> You've built a Lego car (your installed app). An OTA update is like a tiny drone that flies over, removes a broken red brick, and replaces it with a <strong>brand new blue brick</strong> (the new code) that you didn't have before.</p>
<p><strong>Why We Need Them:</strong></p>
<ul>
<li><p><strong>Critical Hotfixes:</strong> This is the number 1 use case. Your app is crashing in production for 10% of users. You can't wait 2 days for an app store review. An OTA update lets you push the one-line fix <em>immediately</em> to all users.</p>
</li>
<li><p><strong>Rapid Iteration:</strong> Push minor UI tweaks, text changes, or bug fixes without the full overhead of a new release cycle.</p>
</li>
</ul>
<p><strong>Important Caveat:</strong> This is a gray area, especially on iOS. Apple's guidelines (2.5.2) state an app cannot "significantly alter" its behavior or purpose. OTA is generally accepted for fixing bugs or pushing small changes in interpreted code (like JavaScript in React Native). For compiled-to-native code (like Flutter), this has historically been complex, but services like <a target="_blank" href="https://shorebird.dev/"><strong>Shorebird</strong></a> have emerged to make this possible.</p>
<p><strong>Popular Tools for OTA:</strong></p>
<ul>
<li><p><a target="_blank" href="https://shorebird.dev/"><strong>Shorebird</strong></a> <strong>(for Flutter):</strong> The leading service for enabling true code push (OTA updates) for Flutter apps. It patches your compiled native code.</p>
</li>
<li><p><a target="_blank" href="https://microsoft.github.io/code-push/"><strong>CodePush</strong></a> <strong>(for React Native):</strong> The long-standing solution, now part of Microsoft's App Center. It pushes new JavaScript bundles.</p>
</li>
<li><p><a target="_blank" href="https://docs.expo.dev/eas-update/introduction/"><strong>EAS Update</strong></a> <strong>(for React Native):</strong> The modern solution from the Expo team, tightly integrated into the Expo ecosystem.</p>
</li>
<li><p><a target="_blank" href="https://codemagic.io/codepush/">CodeMagic CodePush</a>: A drop-in replacement for App Center CodePush</p>
</li>
</ul>
<blockquote>
<p><strong>Key Takeaway:</strong> OTA <em>delivers new code</em> post-install. A Feature Flag <em>toggles existing code</em>. This is the critical difference.</p>
</blockquote>
<h2 id="heading-comparison-flavors-vs-feature-flags-vs-ota">Comparison: Flavors vs. Feature Flags vs. OTA</h2>
<p>Here's the simplest way to remember the difference:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Concept</strong></td><td><strong>Flavors</strong></td><td><strong>Feature Flags</strong></td><td><strong>OTA Updates</strong></td></tr>
</thead>
<tbody>
<tr>
<td><strong>What it does</strong></td><td>Creates different <em>versions</em> of the app</td><td>Remotely <em>toggles</em> features</td><td>Delivers <em>new code</em> to the app</td></tr>
<tr>
<td><strong>When it happens</strong></td><td><strong>Build-Time</strong> (Before compiling)</td><td><strong>Run-Time</strong> (While app is running)</td><td><strong>Post-Install</strong> (While app is running)</td></tr>
<tr>
<td><strong>Primary Goal</strong></td><td>Environments, White-Labeling</td><td>Gradual Rollouts, A/B Testing</td><td>Critical Bug Fixes</td></tr>
<tr>
<td><strong>Analogy</strong></td><td>🍪 Cookie Recipe</td><td>💡 Remote Switch</td><td>🧱 Lego-Bot Brick Swap</td></tr>
<tr>
<td><strong>App Store Bypass?</strong></td><td>No. It creates a <em>new</em> app file to upload.</td><td>Yes. You're just flipping a switch.</td><td>Yes. This is its entire purpose.</td></tr>
</tbody>
</table>
</div><h2 id="heading-do-they-overlap-yes-and-you-should-use-them-together">Do They Overlap? Yes, and You Should Use Them Together.</h2>
<p>These tools are not mutually exclusive; they are designed to be used <em>together</em> for a robust delivery pipeline.</p>
<h3 id="heading-flavors-feature-flags-standard-practice">Flavors + Feature Flags (Standard Practice):</h3>
<p>Your development Flavor points to your dev feature flag server, so your team can test all upcoming features. Your production Flavor points to your prod feature flag server, where all new features are safely "off" by default until you start a gradual rollout.</p>
<h3 id="heading-feature-flags-ota-updates-a-powerful-combo">Feature Flags + OTA Updates (A Powerful Combo):</h3>
<p>This is an advanced, de-risked way to ship.</p>
<ol>
<li><p>You have a bug. You use <strong>OTA</strong> to push the <em>new, fixed code</em> to all users.</p>
</li>
<li><p>But you wrap that new code in a <strong>Feature Flag</strong>, which is "off" by default.</p>
</li>
<li><p>The OTA push finishes. All users now have the new code, but it's not running.</p>
</li>
<li><p>You then use the <strong>Feature Flag</strong> to <em>enable</em> the new code path for 1% of users, then 10%, etc., making sure your fix didn't introduce a <em>new</em> bug.</p>
</li>
</ol>
<h2 id="heading-conclusion-solving-the-whatsapp-mystery">Conclusion: Solving the WhatsApp Mystery</h2>
<p>So, that new feature in your friend's WhatsApp? It was <strong>not</strong> an OTA update. They didn't secretly push new code to your phone. And it was <strong>not</strong> a new Flavor, as you didn't download a new app.</p>
<p>The answer is <strong>Feature Flags</strong>.</p>
<p>The code for that new UI was <em>already</em> included in the last App Store update you downloaded weeks ago. It was just hidden, wrapped in an <code>if (feature.isEnabled)</code> block. When WhatsApp was ready, they flipped a switch on their server, your app checked it, and the <code>if</code> statement became <code>true</code>, revealing the new feature to you.</p>
<p>By understanding the difference between build-time, run-time, and post-install changes, you can move from seeing "magic" to engineering intentional, scalable, and professional software.</p>
]]></content:encoded></item><item><title><![CDATA[Dart on the Server: Unlocking True Full-Stack Potential]]></title><description><![CDATA[A complete guide to full-stack Dart development. Explore backend frameworks like Dart Frog & Serverpod and build modern web frontends with Jaspr. See…]]></description><link>https://developerjamiu.hashnode.dev/dart-on-the-server-unlocking-true-full-stack-potential</link><guid isPermaLink="true">https://developerjamiu.hashnode.dev/dart-on-the-server-unlocking-true-full-stack-potential</guid><dc:creator><![CDATA[Jamiu Okanlawon]]></dc:creator><pubDate>Sat, 19 Jul 2025 23:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1753034280649/314097f8-f244-4c53-afba-e0bd166c64bc.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you’re a developer who has heard of the <a target="_blank" href="https://dart.dev/">Dart language</a>, your mind probably jumps straight to one word: Flutter. You’re not wrong; <a target="_blank" href="https://flutter.dev/">Flutter</a> has been an incredible success story, revolutionizing how we build beautiful, high-performance mobile, web, and desktop applications from a single codebase. The buzz is real and well-deserved.</p>
<p>But that’s not the whole story. To see Dart only as the language for Flutter is to miss out on its most powerful proposition: its potential as a true, end-to-end, full-stack solution. In this article, we’ll move beyond the client and explore the robust, high-performance, and increasingly popular world of Dart on the server.</p>
<h1 id="heading-what-exactly-is-dart-and-a-fun-fact"><strong>What Exactly is Dart? (And a Fun Fact)</strong></h1>
<p>Before we dive into the “why,” let’s cover the “what.” Dart is officially defined as “<strong>An approachable, portable, and productive language for high-quality apps on any platform.</strong>” This philosophy is backed by key features you should know about:</p>
<ul>
<li><p><strong>Type and Null Safety:</strong> Catch errors before you ship with a powerful, sound type system that includes world-class null safety, eliminating entire classes of bugs.</p>
</li>
<li><p><strong>Productive Tooling:</strong> Boost your productivity with features like hot reload, which allows you to see code changes instantly, often without restarting your server.</p>
</li>
<li><p><strong>Optimized for Performance:</strong> Achieve the performance of native code by compiling to fast machine code <a target="_blank" href="https://onuoha.medium.com/how-does-jit-and-aot-work-in-dart-cab2f31d9cb5">(AOT) for production</a>, resulting in quick startup times and low memory usage.</p>
</li>
<li><p><strong>Rich Libraries and Ecosystem:</strong> Get a head start with a comprehensive set of core libraries and tap into thousands of community-built packages on <a target="_blank" href="https://pub.dev/">pub.dev</a> for nearly any task.</p>
</li>
<li><p><strong>Safe Concurrency:</strong> Handle parallel tasks safely and efficiently using <a target="_blank" href="https://dart.dev/language/isolates">Isolates</a>, a message-passing model that avoids the common pitfalls of shared-memory threading.</p>
</li>
</ul>
<p><strong>Fun Fact:</strong> Dart was first unveiled in 2011 with the ambitious goal of being a structured, scalable <a target="_blank" href="https://www.deusinmachina.net/p/the-dart-programming-language-is">replacement for JavaScript</a> in the browser. While it didn’t replace JavaScript, this origin story informs its design. It was built to be a pragmatic and developer-friendly language for complex applications; a DNA that makes it perfectly suited for the server today.</p>
<h1 id="heading-the-full-stack-vision-one-language-to-rule-them-all"><strong>The Full-Stack Vision: One Language to Rule Them All</strong></h1>
<p>In the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript">JavaScript</a> ecosystem, stacks like <a target="_blank" href="https://www.mongodb.com/resources/languages/mean-stack">MEAN</a> (MongoDB, Express, Angular, Node.js) and <a target="_blank" href="https://www.mongodb.com/resources/languages/mern-stack">MERN</a> have gained popularity because they enable developers to use a single language throughout the application. With the addition of <a target="_blank" href="https://reactnative.dev/">React Native</a>, this expanded to mobile, further reducing context-switching and simplifying team collaboration.</p>
<p>Dart takes this concept to the next level. It provides a unified platform not only for web and mobile, but also for <strong>desktop and IoT applications</strong>.</p>
<p>This vision is made practical by Dart’s tooling and project structure. You can have a single monorepo where you share critical code:</p>
<ul>
<li><p><strong>Data Models &amp; DTOs:</strong> Define your <code>User</code> or <code>Product</code> class once and use it everywhere.</p>
</li>
<li><p><strong>Business Logic:</strong> Validation rules, utility functions, and core algorithms are written once in a shared package.</p>
</li>
<li><p><strong>API Client:</strong> Generate a type-safe client for your backend API and share it with your frontend apps.</p>
</li>
<li><p><strong>Configuration:</strong> Dependency injection setups and service locators can be shared.</p>
</li>
<li><p><strong>Constants &amp; Themes:</strong> Colors, strings, and API keys are stored in one place.</p>
</li>
</ul>
<p>A typical full-stack Dart project might look like this:</p>
<pre><code class="lang-plaintext">my_fullstack_project/
├── packages/
│   ├── models/             # Shared data models (User, Product, etc.)
│   │   ├── lib/
│   │   └── pubspec.yaml
│   ├── api_client/         # Auto-generated type-safe client for your API
│   │   ├── lib/
│   │   └── pubspec.yaml
│   └── validation/         # Shared validation logic
│       ├── lib/
│       └── pubspec.yaml
│
├── server/                 # Your Dart backend (e.g., Dart Frog or Serverpod)
│   ├── lib/
│   └── pubspec.yaml
│
├── mobile_app/             # Your Flutter mobile application
│   ├── lib/
│   └── pubspec.yaml
│
└── web_app/                # Your Jaspr or Flutter Web application
    ├── lib/
    └── pubspec.yaml
</code></pre>
<p>In this structure:</p>
<p><code>packages/</code>: This directory is the key to code sharing. It contains local Dart packages that are not applications themselves but provide shared functionality.</p>
<ul>
<li><p><code>models</code>: Define your <code>User</code> or <code>Product</code> class once here, and use it everywhere.</p>
</li>
<li><p><code>api_client</code>: Tools like Serverpod can automatically generate a type-safe client from your backend, which lives here and is used by your mobile and web apps.</p>
</li>
<li><p><code>validation</code>: Shared validation rules (e.g., for email or password formats) can be placed here.</p>
</li>
</ul>
<p><code>server/</code>, <code>mobile_app/</code>, and <code>web_app/</code>: These are the actual applications. Each has its own <code>pubspec.yaml</code> file where they can depend on the shared packages, like this:</p>
<pre><code class="lang-yaml"><span class="hljs-comment"># For example, In mobile_app/pubspec.yaml</span>
<span class="hljs-attr">dependencies:</span>
  <span class="hljs-attr">flutter:</span>
    <span class="hljs-attr">sdk:</span> <span class="hljs-string">flutter</span>
  <span class="hljs-comment"># Depend on the local shared packages</span>
  <span class="hljs-attr">models:</span>
    <span class="hljs-attr">path:</span> <span class="hljs-string">../packages/models</span>
  <span class="hljs-attr">api_client:</span>
    <span class="hljs-attr">path:</span> <span class="hljs-string">../packages/api_client</span>
</code></pre>
<p>This setup allows you to truly define your core business logic and data structures once and use them everywhere, dramatically reducing boilerplate, preventing bugs, and increasing development speed.</p>
<blockquote>
<p><em>Some full-stack frameworks are making this vision a reality. For example,</em> <a target="_blank" href="https://serverpod.dev/"><strong><em>Serverpod</em></strong></a> <em>offers a complete mobile-first full-stack solution with features like code generation and real-time capabilities.</em></p>
</blockquote>
<h1 id="heading-a-smooth-transition-for-modern-developers"><strong>A Smooth Transition for Modern Developers</strong></h1>
<p>If you’re already a backend or full-stack developer, the learning curve for Dart is remarkably gentle.</p>
<p><strong>For JavaScript/TypeScript Developers:</strong> Concepts like <code>async</code>/<code>await</code>, promises (<code>Future</code> in Dart), and modern syntax will make you feel right at home. For a quick intro, check out my articles:</p>
<ul>
<li><p><a target="_blank" href="https://developerjamiu.hashnode.dev/dart-backend-for-nodejs-developers">Dart Backend for Node.js Developers</a></p>
</li>
<li><p><a target="_blank" href="https://developerjamiu.hashnode.dev/dart-shelf-for-expressjs-developers">Dart Shelf for Express.js Developers</a></p>
</li>
</ul>
<p><strong>For C#/Java Developers:</strong> Dart’s object-oriented nature, static typing, and clear syntax will be very familiar territory.</p>
<p>To see this in action, let’s compare something you probably already know: a basic web server. Notice how the core concepts, importing dependencies, creating an app instance, defining routes, and listening on a port, are nearly identical between Express.js and Dart’s <code>shelf</code> package.</p>
<p>The Familiar: Express.js in <code>app.js</code></p>
<p><img src="https://miro.medium.com/v2/resize:fit:1400/1*d3rkBaahlTN000t4RvbSVA.png" alt /></p>
<p>The Familiar: Express.js in <code>app.js</code></p>
<p>The New, Yet Familiar: Dart with <code>shelf</code> in <code>app.dart</code></p>
<p><img src="https://miro.medium.com/v2/resize:fit:1400/1*Z8iuklhnziyTx2leU1oE8Q.png" alt /></p>
<p>The New, Yet Familiar: Dart with <code>shelf</code> in <code>app.dart</code></p>
<p>As you can see, your existing knowledge of how to structure a simple backend application in Node.js is directly transferable to Dart. The names change, but the fundamental patterns for routing and handling requests remain the same, making the transition smooth and intuitive.</p>
<h1 id="heading-building-the-backend-your-framework-options"><strong>Building the Backend: Your Framework Options</strong></h1>
<p>To build the server-side part of your full-stack application, the Dart ecosystem provides several excellent options catering to different needs.</p>
<ul>
<li><p><a target="_blank" href="https://dart.dev/tutorials/server/httpserver"><strong>Vanilla Dart</strong></a> <strong>(</strong><code>dart:io</code><strong>):</strong> For the purists, you can build a web server from scratch using Dart's powerful core libraries. While this gives you maximum control, you'll be reinventing the wheel for routing, middleware, and request handling.</p>
</li>
<li><p><a target="_blank" href="https://github.com/dart-lang/shelf"><strong>Shelf</strong></a><strong>:</strong> This is the foundational, low-level package for building web servers and APIs. It provides a minimal, elegant API for composing handlers and middleware, much like <a target="_blank" href="https://expressjs.com/">Express.js</a> is for <a target="_blank" href="https://nodejs.org/en">Node.js</a>.</p>
</li>
<li><p><a target="_blank" href="https://dartfrog.vgv.dev/"><strong>Dart Frog</strong></a><strong>:</strong> Built by Very Good Ventures, Dart Frog is a fast, minimalistic backend framework that makes building APIs and backends incredibly simple. It focuses on developer experience with features like file-based routing and hot reload, making it a fantastic choice for quickly creating scalable services.</p>
</li>
<li><p><a target="_blank" href="https://serverpod.dev/"><strong>Serverpod</strong></a><strong>:</strong> Although Serverpod is a full-stack solution, it has a powerful backend at its core. It’s a more opinionated, “batteries-included” framework that comes with a high-performance ORM for database communication, real-time communication, authentication, and automatic client generation, saving you immense amounts of boilerplate code.</p>
</li>
</ul>
<h1 id="heading-what-about-the-client-solving-the-web-conundrum-with-jaspr"><strong>What About the Client? Solving the Web Conundrum with Jaspr</strong></h1>
<p>While developers love Flutter for mobile, some have raised valid concerns about <a target="_blank" href="https://flutter.dev/multi-platform/web">Flutter Web</a> for building content-rich, SEO-critical websites. This is where the ecosystem’s flexibility shines. Enter <a target="_blank" href="https://jaspr.site/"><strong>Jaspr</strong></a>.</p>
<p>Jaspr is a modern web framework for Dart that feels just like using <a target="_blank" href="https://react.dev/">React</a> or <a target="_blank" href="https://vuejs.org/">Vue</a>. It embraces component-based architecture and state management, but allows you to write in the type-safe, robust Dart language. Crucially, it renders to standard HTML and supports both <a target="_blank" href="https://docs.jaspr.site/get_started/modes#static-mode"><strong>Client-Side Rendering (CSR)</strong></a> and <a target="_blank" href="https://docs.jaspr.site/get_started/modes#server-mode"><strong>Server-Side Rendering (SSR)</strong></a>, solving the SEO and performance problems for web applications.</p>
<p>Let’s look at the simplest possible “Hello World” component in both frameworks. Notice how similar the structure and concepts are.</p>
<p>The Familiar: React with JSX</p>
<p><img src="https://miro.medium.com/v2/resize:fit:1400/1*-f0emswGppzs_j-Fqb856w.png" alt /></p>
<p>The New: Jaspr in Dart</p>
<p><img src="https://miro.medium.com/v2/resize:fit:1400/1*7ZQs949S06oQkm5LQ5FeUA.png" alt /></p>
<p>To learn more, I wrote an introduction here: <a target="_blank" href="https://developerjamiu.hashnode.dev/jaspr-for-flutter-developers"><strong>Jaspr for Flutter Developers</strong></a></p>
<h1 id="heading-the-reality-challenges-and-immense-opportunities"><strong>The Reality: Challenges and Immense Opportunities</strong></h1>
<p>No ecosystem is perfect, and it’s important to be honest about the current state of Dart on the server. The ecosystem is growing rapidly, but it’s younger than its counterparts. This means:</p>
<ul>
<li><p><strong>Fewer Mature Libraries:</strong> You may find that some specific backend libraries, particularly in the case of Object-Relational Mappers (ORMs), either don’t quite meet your specific requirements or may lack extensive documentation.</p>
</li>
<li><p><strong>Less Fundamental Content:</strong> Compared to Node.js or Go, there are fewer deep-dive books, courses, and articles on advanced Dart backend topics.</p>
</li>
</ul>
<p>However, these gaps represent a massive <strong>opportunity</strong>. The community is vibrant, inviting, and actively building the future. You have a chance to not just use the technology, but to shape it.</p>
<p>Incredible work is already being done by key players:</p>
<ul>
<li><p><a target="_blank" href="https://verygood.ventures/"><strong>Very Good Ventures (VGV)</strong></a><strong>:</strong> Creators of Dart Frog, an easy-to-use web framework built on Shelf.</p>
</li>
<li><p><a target="_blank" href="https://serverpod.dev/"><strong>Serverpod</strong></a><strong>:</strong> The team building a complete, open-source, full-stack framework for Dart.</p>
</li>
<li><p><a target="_blank" href="https://github.com/schultek"><strong>The Jaspr Author</strong></a><strong>:</strong> Pushing the boundaries of Dart for server-rendered web apps.</p>
</li>
<li><p><a target="_blank" href="https://invertase.io/"><strong>Invertase</strong></a><strong>:</strong> The company behind <a target="_blank" href="https://globe.dev/"><strong>Globe</strong></a>, a product dedicated to solving the ecosystem’s biggest challenges, from deployment to interoperability.</p>
</li>
</ul>
<p>One of Invertase’s most exciting innovations is the <a target="_blank" href="https://pub.dev/packages/globe_runtime"><strong>Globe Runtime</strong></a>, which allows you to call TypeScript libraries and functions directly from your Dart code. This is a <a target="_blank" href="https://globe.dev/blog/building-the-bridge/">game-changer</a>, as it means you can bring your favorite, battle-tested <a target="_blank" href="https://www.npmjs.com/">npm</a> package into your Dart project, bridging the library gap while the native ecosystem continues to mature.</p>
<h1 id="heading-whos-using-dart-on-the-server"><strong>Who’s Using Dart on the Server?</strong></h1>
<p>Dart on the server isn’t just an experiment; it’s proven in production by the team that knows it best and by a growing community.</p>
<ul>
<li><p><strong>At Google:</strong> The most prominent example is the backend for <a target="_blank" href="https://pub.dev/"><strong>pub.dev</strong></a>, the official package repository, which is a complex application built with Dart.</p>
</li>
<li><p><strong>In the Community (Backend):</strong> Real-world applications are being built with Dart’s server-side frameworks. For example, <a target="_blank" href="https://www.myopnotes.co.uk/"><strong>MyOpNotes</strong></a>, a tool for healthcare professionals, uses <strong>Dart Frog</strong> for its backend, while the tech platform <a target="_blank" href="https://morel.technology/"><strong>Morel</strong></a> is built using <strong>Serverpod</strong>.</p>
</li>
<li><p><strong>In the Community (Web Frontend):</strong> Reinforcing the full-stack vision, modern web frontends are being built with Dart. The websites for <a target="_blank" href="https://www.compilecamp.com/"><strong>Compile Camp</strong></a>, the <a target="_blank" href="https://flutteristas.org/"><strong>Flutteristas</strong></a>, and <a target="_blank" href="https://www.flutteryeg.com/"><strong>Flutter Edmonton</strong></a> are all built with <strong>Jaspr</strong>, showcasing its power for creating fast, content-driven sites.</p>
</li>
</ul>
<h1 id="heading-deployment-solved-a-spotlight-on-globedev"><strong>Deployment, Solved: A Spotlight on Globe.dev</strong></h1>
<p>Once you’ve built your Dart server, where do you run it? Because Dart compiles to a self-contained native executable, it’s easy to containerize with <a target="_blank" href="https://www.docker.com/"><strong>Docker</strong></a> and deploy to <a target="_blank" href="https://cloud.google.com/run?hl=en">Google Cloud Run</a>, <a target="_blank" href="https://aws.amazon.com/apprunner/">AWS App Runner</a>, or <a target="_blank" href="https://www.digitalocean.com/">DigitalOcean</a>.</p>
<p>But for the most streamlined experience, there is a platform built <em>specifically</em> for the Dart and Flutter ecosystem. <a target="_blank" href="https://globe.dev/"><strong>Globe.dev</strong></a> is currently the only purpose-built platform for deploying general Dart and Flutter projects, and it’s my personal favorite. It’s designed to make deployment effortless and is tailored for Dart developers. It’s the fastest way to get your Dart backend, Jaspr apps, and Flutter web apps into production.</p>
<h1 id="heading-how-to-get-started-with-dart-on-the-server"><strong>How to Get Started with Dart on the Server</strong></h1>
<p>Feeling inspired? Here’s a path to get started:</p>
<ol>
<li><p><strong>Learn the Language:</strong> There are a lot of free guides to take you through Dart, like the one at <a target="_blank" href="https://dart-tutorial.com/">dart-tutorial.com</a>. If you prefer visual learning, you could explore videos on <a target="_blank" href="https://www.youtube.com/watch?v=F3JuuYuOUK4&amp;t=5s">YouTube</a> or “The Complete Dart Developer Guide” from <a target="_blank" href="https://codewithandrea.com/courses/complete-dart-guide/">Code with Andrea</a>, which I highly recommend.</p>
</li>
<li><p><strong>Explore Backend Frameworks:</strong> Read through my The <a target="_blank" href="https://dart-shelf.hashnode.space/"><strong>Dart &amp; Shelf Backend Handbook</strong></a> to understand the foundations. You can also check out the <a target="_blank" href="https://dartfrog.vgv.dev/docs/overview">DartFrog</a>, <a target="_blank" href="https://docs.serverpod.dev/">Serverpod</a>, and <a target="_blank" href="https://docs.jaspr.site/">Jaspr</a> docs.</p>
</li>
<li><p><strong>Read, Watch, and Connect:</strong> Check out the Hashnode articles linked above and explore videos from the official Dart and Flutter YouTube channels. The <a target="_blank" href="https://docs.globe.dev/guides/?dartServerArticle=true"><strong>Globe.dev guide pages</strong></a> are also an excellent resource.</p>
</li>
</ol>
<blockquote>
<p><em>Dart for backend development will be easiest for those who already understand web fundamentals (REST APIs, databases, etc.). However, because the language is so clear and the community is so inviting, even those just starting their journey can find success.</em></p>
</blockquote>
<p>The potential of Dart to unify the entire development stack is no longer a future promise; it’s happening now. The tools are here, the community is growing, and the opportunity to build amazing things is wide open.</p>
<hr />
<p><em>Have questions about Dart on the server or getting started with</em> <a target="_blank" href="https://globe.dev/"><em>Globe.dev</em></a><em>? Connect with me on X (formerly Twitter) at</em> <a target="_blank" href="https://twitter.com/developerjamiu"><em>@developerjamiu</em></a><em>.</em></p>
]]></content:encoded></item><item><title><![CDATA[Jaspr for Flutter Developers: Bridging the Gap to Web Development]]></title><description><![CDATA[Learn Jaspr to build native HTML/CSS websites with Dart. Bridge the gap from Flutter, using familiar Dart skills for SEO-friendly, modern web development.]]></description><link>https://developerjamiu.hashnode.dev/jaspr-for-flutter-developers</link><guid isPermaLink="true">https://developerjamiu.hashnode.dev/jaspr-for-flutter-developers</guid><category><![CDATA[Dart]]></category><category><![CDATA[Flutter]]></category><category><![CDATA[jaspr]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Jamiu Okanlawon]]></dc:creator><pubDate>Thu, 29 May 2025 14:30:30 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1748528309555/7fe4979f-ac6b-48c3-a1a9-3cd51c3827f0.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>You're a Flutter developer. You're comfortable with Dart, the reactive widget tree, and building beautiful, cross-platform applications. You understand <code>StatelessWidget</code> and <code>StatefulWidget</code>, the intricacies of <code>BuildContext</code>, and how <code>Column</code> and <code>Row</code> magically arrange your UI. But then comes the web, a platform that often feels fundamentally different.</p>
<p>Flutter Web is an incredible technology for bringing your <em>apps</em> to the browser, offering pixel-perfect consistency across platforms by rendering to a canvas. However, as the Flutter team themselves often clarify, Flutter Web is optimized for <strong>web applications</strong>, not necessarily for <strong>web<em>sites</em></strong>. For content-heavy pages, SEO, accessibility, and integrati<strong>on with the vast ecosystem of web standards (HTML, CSS, JavaScript) may not always make Flutter Web</strong> the ideal fit.</p>
<p><strong>This is where Jaspr steps in.</strong></p>
<p>Jaspr is a modern web framework for Dart developers, designed to feel remarkably familiar to anyone coming from Flutter, yet it renders native HTML and CSS. It's an alternative to Flutter Web when your goal is to build any kind of website, from static pages and server-rendered sites to single-page applications. With Jaspr, you get the comfort of your beloved Dart and the familiar component model, but you're building directly for the open web, embracing its unique properties.</p>
<p>This article is for you, the Flutter developer who doesn't have prior web development experience. We'll highlight the key conceptual shifts and practical differences you need to understand to succeed and truly thrive with Jaspr.</p>
<h2 id="heading-jasprs-core-philosophy-flutter-like-web-native">Jaspr's Core Philosophy: Flutter-like, Web-Native</h2>
<p>Jaspr aims to give you the best of both worlds: the development experience you love from Flutter, combined with the native power and flexibility of the web.</p>
<h3 id="heading-the-fluttery-feeling">The "Fluttery Feeling"</h3>
<p>When you look at Jaspr code, you'll immediately recognize patterns. You'll work with <code>StatelessComponent</code> and <code>StatefulComponent</code> classes, each with a <code>build</code> method. You'll define your UI in a declarative manner, composing smaller components into larger ones. This similarity significantly lowers the barrier to entry, allowing you to reuse your mental models for UI composition and state management.</p>
<h3 id="heading-the-web-native-reality">The "Web-Native Reality"</h3>
<p>Here's the crucial distinction from Flutter Web: <strong>Jaspr doesn't draw pixels to a canvas.</strong> Instead, it directly manipulates the browser's Document Object Model (DOM). This means that when you create a <code>Div</code> component in Jaspr, it ultimately translates into a <code>&lt;div&gt;</code> HTML element in the browser. A <code>Text</code> component becomes a text node, and so on.</p>
<p>Jaspr embraces core web standards like HTML for structure, CSS for styling, and JavaScript (under the hood) for dynamic behavior. This isn't a limitation; it's a fundamental strength for building highly performant, accessible, and SEO-friendly websites that play well with the rest of the internet. By understanding this underlying reality, you'll gain powerful control over your web projects.</p>
<h2 id="heading-key-differences-for-flutter-developers-and-how-to-adapt">Key Differences for Flutter Developers (and How to Adapt)</h2>
<p>While the <code>Component</code> abstraction feels familiar, the underlying web platform requires a shift in perspective. Let's break down the most significant differences and how you can adapt.</p>
<h3 id="heading-1-building-views-from-single-widget-to-iterable-components">1. Building Views: From Single Widget to Iterable Components</h3>
<p>In Flutter, your <code>build()</code> method typically returns a single <code>Widget</code>, even if it's a <code>Column</code> or <code>Row</code> containing many children. This is because Flutter's render object tree expects a single root.</p>
<p><strong>Flutter Way:</strong></p>
<pre><code class="lang-dart"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyWidget</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">StatelessWidget</span> </span>{
  <span class="hljs-meta">@override</span>
  Widget build(BuildContext context) {
    <span class="hljs-keyword">return</span> Column( <span class="hljs-comment">// Single root widget</span>
      children: [
        Text(<span class="hljs-string">'Hello'</span>),
        Text(<span class="hljs-string">'Flutter!'</span>),
      ],
    );
  }
}
</code></pre>
<p>In Jaspr, the <code>build()</code> method of a <code>StatelessComponent</code> or <code>StatefulComponent</code> returns an <code>Iterable&lt;Component&gt;</code>. This might seem unusual at first, but it perfectly maps to how HTML works: a parent HTML element can directly contain multiple child elements without needing an explicit "wrapper" element like a <code>Column</code> or <code>Row</code> at every level.</p>
<p>The recommended way to use this is with a <strong>synchronous generator function</strong> (<code>sync*</code> and <code>yield</code>).</p>
<p><strong>Jaspr Way:</strong></p>
<pre><code class="lang-dart"><span class="hljs-keyword">import</span> <span class="hljs-string">'package:jaspr/jaspr.dart'</span>;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyComponent</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">StatelessComponent</span> </span>{
  <span class="hljs-meta">@override</span>
  <span class="hljs-built_in">Iterable</span>&lt;Component&gt; build(BuildContext context) <span class="hljs-keyword">sync</span>* {
    <span class="hljs-keyword">yield</span> Text(<span class="hljs-string">'Hello'</span>);
    <span class="hljs-keyword">yield</span> Text(<span class="hljs-string">'Jaspr!'</span>); <span class="hljs-comment">// Another direct child of MyComponent's parent</span>
  }
}
</code></pre>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Think of <code>yield</code> as directly adding an HTML element to the parent container that rendered <code>MyComponent</code>. If you want to group elements, use a <code>Div</code> or other appropriate HTML component (like <code>Section</code>, <code>Article</code>, <code>Span</code>) to contain them, just as you'd use a <code>Column</code> or <code>Row</code> in Flutter.</div>
</div>

<h3 id="heading-2-styling-embracing-css-in-dart-and-the-webs-styling-paradigm"><strong>2. Styling: Embracing CSS-in-Dart and the Web's Styling Paradigm</strong></h3>
<p>In Flutter, styling is often intrinsically tied to your widgets. You'd use <code>TextStyle</code> for <code>Text</code> or various properties directly on a <code>Container</code>. The web, however, fundamentally separates content (HTML) from presentation (CSS).</p>
<p>Jaspr beautifully bridges this gap by providing a powerful CSS-in-Dart system. This means you get to write your styles using familiar Dart code and its strong type system, which Jaspr then intelligently compiles into standard CSS. Let's look at the ways you can manage your styles.</p>
<p><strong>Flutter Way (Conceptual Reminder):</strong></p>
<pre><code class="lang-dart">Text(
  <span class="hljs-string">'Styled Text'</span>,
  style: TextStyle(fontSize: <span class="hljs-number">20</span>, color: Colors.blue)
);
Container(
  padding: EdgeInsets.all(<span class="hljs-number">16</span>),
  color: Colors.red,
  child: Text(<span class="hljs-string">'My Box'</span>)
);
</code></pre>
<p><strong>Jaspr Way:</strong></p>
<p><strong>Component Styles (Recommended for Locality):</strong> For a clean codebase, define styles right inside your components using the <code>@css</code> annotation on a static <code>styles</code> field. This promotes code locality, meaning a component's logic and its specific styles live side-by-side.</p>
<pre><code class="lang-dart"><span class="hljs-keyword">import</span> <span class="hljs-string">'package:jaspr/jaspr.dart'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">'package:jaspr_ui/jaspr_ui.dart'</span>; <span class="hljs-comment">// Often needed for Styles, Colors etc.</span>

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">App</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">StatelessComponent</span> </span>{
  <span class="hljs-keyword">const</span> App({<span class="hljs-keyword">super</span>.key});

  <span class="hljs-meta">@override</span>
  <span class="hljs-built_in">Iterable</span>&lt;Component&gt; build(BuildContext context) <span class="hljs-keyword">sync</span>* {
    <span class="hljs-keyword">yield</span> div(classes: <span class="hljs-string">'main'</span>, [ <span class="hljs-comment">// Applying a CSS class defined below</span>
      p([text(<span class="hljs-string">'Hello World'</span>)]),
    ]);
  }

  <span class="hljs-meta">@css</span> <span class="hljs-comment">// This annotation tells Jaspr to generate CSS from these styles</span>
  <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> styles = [
    css(<span class="hljs-string">'.main'</span>, [ <span class="hljs-comment">// Targeting elements with the 'main' class</span>
      css(<span class="hljs-string">'&amp;'</span>).styles( <span class="hljs-comment">// '&amp;' refers to the current selector, in this case '.main'</span>
        width: <span class="hljs-number">100.</span>px,
        padding: Padding.all(<span class="hljs-number">10.</span>rem),
      ),
      css(<span class="hljs-string">'p'</span>).styles( <span class="hljs-comment">// Targeting &lt;p&gt; tags *inside* '.main'</span>
        color: Colors.blue,
      ),
    ]),
  ];
}
</code></pre>
<p><strong>Global Stylesheets (Defined in Dart):</strong> If you have styles that apply across your entire website, you can define them globally from your Dart code, often in your <code>main.dart</code> file by passing <code>StyleRule</code>s to the <code>Document</code> component's <code>styles</code> parameter, or by using the <code>@css</code> annotation on a global variable.</p>
<p><strong>Inline Styles:</strong> For quick, component-specific styling, you can pass a <code>Styles</code> instance directly to any HTML component using its <code>styles</code> attribute. While convenient, it's generally best practice to use component or global stylesheets for better maintainability.</p>
<pre><code class="lang-dart">div(styles: <span class="hljs-keyword">const</span> Styles(backgroundColor: Colors.red), []);
<span class="hljs-comment">// This will render HTML like: &lt;div style="background-color: red"&gt;&lt;/div&gt;</span>
</code></pre>
<p><strong>Responsive Styling:</strong> Jaspr provides a type-safe way to write CSS <code>@media</code> queries directly in Dart using <a target="_blank" href="http://css.media"><code>css.media</code></a><code>()</code>. This lets you define different styles that automatically adjust based on screen characteristics.</p>
<pre><code class="lang-dart"><span class="hljs-meta">@css</span>
<span class="hljs-keyword">final</span> styles = [
    css(<span class="hljs-string">'.main'</span>).styles(
      display: Display.flex,
      flexDirection: FlexDirection.row, <span class="hljs-comment">// Default layout for larger screens</span>
    ),
    css.media(MediaQuery.screen(maxWidth: <span class="hljs-number">600.</span>px), [ <span class="hljs-comment">// When the screen is 600px wide or less</span>
      css(<span class="hljs-string">'.main'</span>).styles(
        flexDirection: FlexDirection.column, <span class="hljs-comment">// Switch to a column layout</span>
      ),
    ]),
];
</code></pre>
<p><strong>Integrating Traditional Web Styling:</strong> Jaspr also embraces traditional web development workflows:</p>
<ul>
<li><p><strong>External Stylesheets (.css files):</strong> If you prefer writing plain CSS, you can easily link them.</p>
<ul>
<li><p><strong>Static/Server Mode:</strong> Add a <code>&lt;link&gt;</code> tag within the <code>Document</code> component's <code>head</code> property in <code>lib/main.dart</code>.</p>
<pre><code class="lang-dart">  <span class="hljs-keyword">void</span> main() {
    runApp(Document(
      head: [
        link(rel: <span class="hljs-string">"stylesheet"</span>, href: <span class="hljs-string">"/path/to/your/stylesheet.css"</span>),
      ],
      body: App(),
    ));
  }
</code></pre>
</li>
<li><p><strong>Client Mode:</strong> Add the <code>&lt;link&gt;</code> tag directly to your <code>web/index.html</code> file within the <code>&lt;head&gt;</code> section.</p>
</li>
</ul>
</li>
<li><p><strong>Third-Party CSS Frameworks:</strong> Integrate frameworks like Tailwind CSS or Bulma by linking their stylesheets and applying their predefined classes to your Jaspr components.</p>
</li>
<li><p><strong>CSS Preprocessors (e.g., Dart Sass):</strong> Use preprocessors like Sass and link the compiled <code>.css</code> output as an external stylesheet.</p>
</li>
</ul>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Start by exploring Jaspr's <strong>CSS-in-Dart</strong> system; its type-safety and Dart familiarity will feel comfortable. However, for a truly deep understanding and mastery of web styling, it's invaluable to grasp the fundamental concepts of <strong>CSS Box Model</strong>, <strong>Flexbox</strong>, <strong>CSS Grid</strong>, and <strong>Media Queries</strong>. Even when writing CSS-in-Dart, this foundational web knowledge is key to crafting effective layouts and truly responsive designs. Also, remember that a <code>Text</code> component in Jaspr won't have direct style properties like in Flutter; all text styling is applied through CSS rules to its containing HTML element.</div>
</div>

<h3 id="heading-3-layout-amp-responsiveness-flexbox-grid-amp-media-queries-not-columnrow-amp-mediaquery">3. Layout &amp; Responsiveness: Flexbox, Grid, &amp; Media Queries (Not <code>Column</code>/<code>Row</code> &amp; <code>MediaQuery</code>)</h3>
<p>Flutter relies heavily on <code>Column</code>, <code>Row</code>, <code>Stack</code>, and <code>Expanded</code> widgets, often combined with <code>MediaQuery.of(context).size</code> for responsive layouts.</p>
<p><strong>Flutter Way (Conceptual):</strong></p>
<pre><code class="lang-dart"><span class="hljs-comment">// Arrangement</span>
Column(
  children: [
    Expanded(child: BlueBox()),
    GreenBox(),
  ],
)

<span class="hljs-comment">// Responsiveness</span>
<span class="hljs-keyword">if</span> (MediaQuery.of(context).size.width &lt; <span class="hljs-number">600</span>) {
  <span class="hljs-comment">// Mobile layout</span>
} <span class="hljs-keyword">else</span> {
  <span class="hljs-comment">// Desktop layout</span>
}
</code></pre>
<p>In Jaspr, you'll use standard web layout techniques, primarily <strong>CSS Flexbox</strong> and <strong>CSS Grid</strong>, combined with <strong>CSS Media Queries</strong> for responsiveness.</p>
<ul>
<li><p><strong>Flexbox:</strong> Your go-to for one-dimensional layouts, arranging items in a row or a column. It's incredibly powerful for distributing space and aligning content.</p>
</li>
<li><p><strong>CSS Grid:</strong> Ideal for two-dimensional layouts, often used for overall page structure (headers, sidebars, main content, footers).</p>
</li>
<li><p><strong>Media Queries:</strong> The web's native way to apply different styles or layouts based on screen characteristics like width, height, or orientation. CSS</p>
<pre><code class="lang-css">  <span class="hljs-comment">/* styles.css */</span>
  <span class="hljs-selector-class">.container</span> {
      <span class="hljs-attribute">display</span>: flex;
      <span class="hljs-attribute">flex-direction</span>: column; <span class="hljs-comment">/* Default for mobile */</span>
  }

  <span class="hljs-keyword">@media</span> (<span class="hljs-attribute">min-width:</span> <span class="hljs-number">768px</span>) { <span class="hljs-comment">/* When screen is at least 768px wide */</span>
      <span class="hljs-selector-class">.container</span> {
          <span class="hljs-attribute">flex-direction</span>: row; <span class="hljs-comment">/* Change to row for wider screens */</span>
          <span class="hljs-attribute">justify-content</span>: space-around;
      }
      <span class="hljs-selector-class">.item</span> {
          <span class="hljs-attribute">width</span>: <span class="hljs-number">30%</span>;
      }
  }
</code></pre>
</li>
<li><p><strong>No</strong> <code>MediaQuery.of(context).size</code> for layout: You won't typically query screen size programmatically in Jaspr for layout decisions. Instead, you'll define breakpoints directly in your CSS using media queries, letting the browser handle the layout changes automatically.</p>
</li>
</ul>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Master Flexbox. It's the bread and butter of modern web layouts. Then, explore CSS Grid for more complex page structures. Understanding how to use media queries to create truly responsive designs is also essential.</div>
</div>

<h3 id="heading-4-handling-text-pure-strings-css-for-styling">4. Handling Text: Pure Strings, CSS for Styling</h3>
<p>In Flutter, the <code>Text</code> widget is very versatile, allowing you to specify a <code>String</code> and then apply a <code>TextStyle</code> directly.</p>
<p><strong>Flutter Way:</strong></p>
<pre><code class="lang-dart">Text(
  <span class="hljs-string">'My Title'</span>,
  style: TextStyle(
    fontSize: <span class="hljs-number">24</span>,
    fontWeight: FontWeight.bold,
  ),
)
</code></pre>
<p>In Jaspr, the <code>Text</code> component (or more commonly, HTML elements like <code>P</code>, <code>H1</code>, <code>Span</code>) only takes a <code>String</code> (or children). All styling, including font size, weight, color, line height, etc., is handled externally via CSS.</p>
<p><strong>Jaspr Way:</strong></p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> <span class="hljs-string">'package:jaspr/jaspr.dart'</span>;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyTitle</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">StatelessComponent</span> </span>{
  @override
  Iterable&lt;Component&gt; build(BuildContext context) sync* {
    <span class="hljs-keyword">yield</span> H1(classes: [<span class="hljs-string">'page-title'</span>], <span class="hljs-attr">children</span>: [
      Text(<span class="hljs-string">'My Title'</span>),
    ]);
  }
}
</code></pre>
<pre><code class="lang-css"><span class="hljs-comment">/* styles.css */</span>
<span class="hljs-selector-class">.page-title</span> {
    <span class="hljs-attribute">font-size</span>: <span class="hljs-number">2em</span>; <span class="hljs-comment">/* 2 times the root font size */</span>
    <span class="hljs-attribute">font-weight</span>: bold;
    <span class="hljs-attribute">color</span>: <span class="hljs-number">#333</span>;
    <span class="hljs-attribute">text-align</span>: center;
}
</code></pre>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Don't expect to pass styling properties directly to your <code>Text</code> component. Instead, think about which HTML element (<code>H1</code>-<code>H6</code>, <code>P</code>, <code>Span</code>) semantically fits your text, then apply CSS classes or inline styles to that element or its parent.</div>
</div>

<h2 id="heading-whats-familiar-amp-why-jaspr-is-still-great-for-you">What's Familiar &amp; Why Jaspr is Still Great for You</h2>
<p>Despite the differences, Jaspr offers tremendous advantages for Flutter developers:</p>
<ul>
<li><p><strong>Dart!</strong> This is the biggest win. You write all your code, from UI logic to server-side rendering, in a single, familiar language. No context switching to JavaScript, no Node.js for the backend unless you choose it.</p>
</li>
<li><p><strong>Component/Widget Model:</strong> The core paradigm of composing UI from smaller, reusable components remains. Your experience with breaking down Flutter UIs into smaller widgets directly translates.</p>
</li>
<li><p><strong>State Management:</strong> Most of your preferred Dart state management solutions (Riverpod, BLoC, MobX, etc.) are all perfectly compatible with Jaspr, as they operate on Dart objects and streams, independent of the rendering layer.</p>
</li>
<li><p><strong>Package Ecosystem:</strong> The vast majority of non-UI-specific Dart packages on pub.dev are available to you. Need HTTP requests? JSON serialization? Utility functions? They're all there.</p>
</li>
<li><p><strong>Server-Side Rendering (SSR):</strong> Jaspr provides SSR out of the box. This is a powerful web feature that improves initial load times, enhances SEO, and can provide a better user experience, especially on slower networks.</p>
</li>
<li><p><strong>JasprPad:</strong> The online editor and playground, JasprPad, is an invaluable tool for experimenting with Jaspr live in the browser without any local setup. It's built with Jaspr itself, demonstrating its capabilities!</p>
</li>
<li><p><strong>Flutter Web Embedding:</strong> For those niche cases where a specific part of your website genuinely benefits from Flutter's canvas rendering (e.g., complex animations, custom UI elements), Jaspr offers first-class support for embedding Flutter Web apps within your Jaspr site.</p>
</li>
</ul>
<h2 id="heading-getting-started-amp-next-steps">Getting Started &amp; Next Steps</h2>
<p>Ready to build your first Jaspr website? Here’s how to transition smoothly:</p>
<ul>
<li><p><strong>Consult the Official</strong> <a target="_blank" href="https://jaspr.site/"><strong>Jaspr Documentation</strong></a><strong>:</strong> This is your primary resource for setup, core concepts, and advanced features.</p>
</li>
<li><p><strong>Experiment with</strong> <a target="_blank" href="https://playground.jaspr.site/"><strong>JasprPad</strong></a><strong>:</strong> Dive in immediately and try out the samples or the tutorial. You can even download your work as a complete Dart project to continue locally.</p>
</li>
<li><p><strong>Focus on</strong> <a target="_blank" href="https://www.freecodecamp.org/learn/2022/responsive-web-design/"><strong>Web Fundamentals</strong></a><strong>:</strong></p>
<ul>
<li><p><strong>HTML Semantics:</strong> Understand the difference between <code>&lt;div&gt;</code> (generic container) and <code>&lt;h1&gt;</code>, <code>&lt;p&gt;</code>, <code>&lt;a&gt;</code>, <code>&lt;nav&gt;</code>, <code>&lt;section&gt;</code>, <code>&lt;article&gt;</code>. Using the right HTML element improves accessibility and SEO.</p>
</li>
<li><p><strong>CSS Basics:</strong> Get comfortable with the Box Model (padding, border, margin), <code>display</code> properties (<code>block</code>, <code>inline</code>, <code>inline-block</code>, <code>flex</code>, <code>grid</code>), and positioning.</p>
</li>
<li><p><strong>Browser Developer Tools:</strong> Learn to use your browser's Inspect Element feature (usually F12 or right-click -&gt; Inspect). This tool is indispensable for debugging layouts, styles, and understanding the DOM.</p>
</li>
</ul>
</li>
<li><p><strong>Join the</strong> <a target="_blank" href="https://discord.com/invite/XGXrGEk4c6"><strong>Jaspr Community</strong></a><strong>:</strong> The Discord community is a great place to ask questions and learn from other developers.</p>
</li>
</ul>
<h2 id="heading-conclusion-your-web-journey-begins">Conclusion: Your Web Journey Begins!</h2>
<p>Jaspr truly empowers Flutter developers to expand their horizons and confidently build for the web. While it requires an initial adaptation to web paradigms like HTML, CSS, Flexbox, and Grid, the core familiarity of Dart and the component-based development model makes it an incredibly smooth and rewarding transition.</p>
<p>You're no longer just building apps; you're building websites. Dive in, embrace the web, and create fast, dynamic, and native web experiences, all powered by Dart. Your web development journey with Jaspr is just beginning!</p>
]]></content:encoded></item><item><title><![CDATA[Dart Shelf for Express.js Developers: A Familiar Look at Backend Dart]]></title><description><![CDATA[Don't start from scratch. See how your Express.js knowledge of routing, middleware, and server setup gives you a head start in building backends with Shelf]]></description><link>https://developerjamiu.hashnode.dev/dart-shelf-for-expressjs-developers</link><guid isPermaLink="true">https://developerjamiu.hashnode.dev/dart-shelf-for-expressjs-developers</guid><category><![CDATA[Express]]></category><category><![CDATA[Dart]]></category><category><![CDATA[backend]]></category><category><![CDATA[APIs]]></category><dc:creator><![CDATA[Jamiu Okanlawon]]></dc:creator><pubDate>Wed, 28 May 2025 06:11:43 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1748416011509/e0565e0f-4941-4808-bd79-291e4f5a9f70.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you're a <a target="_blank" href="https://nodejs.org/en">Node.js</a> developer, you probably live and breathe <a target="_blank" href="https://expressjs.com/">Express.js</a>. Its simplicity, flexibility, and powerful middleware pattern have made it the undisputed king of Node backend frameworks. But what if you're curious about Dart, especially if you're using Flutter for your frontend? You might assume you have to learn a completely new set of backend concepts.</p>
<p>The good news is, you don't.</p>
<p>This guide is for you, the Express.js developer. We'll show you how Dart's Shelf framework uses concepts so similar to Express that you'll feel right at home. Let's see how your existing skills give you a massive head start.</p>
<h2 id="heading-the-core-idea-mapping-concepts">The Core Idea: Mapping Concepts</h2>
<p>The key to learning Shelf is realizing that the core concepts are the same, just with a different (and type-safe!) syntax.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Express.js Concept</strong></td><td><strong>Dart Shelf Equivalent</strong></td><td><strong>The Short Version</strong></td></tr>
</thead>
<tbody>
<tr>
<td><code>express()</code></td><td><code>Router()</code> or <code>Pipeline()</code></td><td>The main entry point for your app.</td></tr>
<tr>
<td><code>req</code>, <code>res</code></td><td><code>Request request</code></td><td>Shelf uses a single <code>Request</code> object and you return a <code>Response</code>.</td></tr>
<tr>
<td><code>app.use(middleware)</code></td><td><code>Pipeline().addMiddleware()</code></td><td>The concept of using middleware is identical.</td></tr>
<tr>
<td><a target="_blank" href="http://req.params.id"><code>req.params.id</code></a></td><td><code>(Request r, String id)</code></td><td>Route parameters are passed as function arguments.</td></tr>
<tr>
<td><code>npm install</code></td><td><code>dart pub add</code></td><td>How you add your dependencies.</td></tr>
</tbody>
</table>
</div><h2 id="heading-1-your-first-server-from-applisten-to-ioserve">1. Your First Server: From <code>app.listen</code> to <code>io.serve</code></h2>
<p>In Express, you create an app instance and tell it to listen on a port.</p>
<p><code>app.js</code> (Express)</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> express = <span class="hljs-built_in">require</span>(<span class="hljs-string">'express'</span>);
<span class="hljs-keyword">const</span> app = express();
<span class="hljs-keyword">const</span> port = <span class="hljs-number">3000</span>;

app.get(<span class="hljs-string">'/'</span>, <span class="hljs-function">(<span class="hljs-params">req, res</span>) =&gt;</span> {
  res.send(<span class="hljs-string">'Hello from Express!'</span>);
});

app.listen(port, <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Server running at http://localhost:<span class="hljs-subst">${port}</span>`</span>);
});
</code></pre>
<p>Now, let's "translate" that to Dart and Shelf. Notice how the structure feels familiar. We create a handler for requests and serve it.</p>
<p><code>server.dart</code> (Shelf)</p>
<pre><code class="lang-dart"><span class="hljs-keyword">import</span> <span class="hljs-string">'package:shelf/shelf.dart'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">'package:shelf/shelf_io.dart'</span> <span class="hljs-keyword">as</span> io;

<span class="hljs-keyword">void</span> main() <span class="hljs-keyword">async</span> {
  <span class="hljs-comment">// This handler is like your (req, res) =&gt; { ... } callback</span>
  <span class="hljs-keyword">final</span> handler = (Request request) {
    <span class="hljs-keyword">return</span> Response.ok(<span class="hljs-string">'Hello from Shelf!'</span>);
  };

  <span class="hljs-comment">// This is the equivalent of app.listen()</span>
  <span class="hljs-keyword">final</span> server = <span class="hljs-keyword">await</span> io.serve(handler, <span class="hljs-string">'localhost'</span>, <span class="hljs-number">3000</span>);
  <span class="hljs-built_in">print</span>(<span class="hljs-string">'Server running on port <span class="hljs-subst">${server.port}</span>'</span>);
}
</code></pre>
<p>The core logic is the same: define what to do when a request comes in, and then start the server.</p>
<h2 id="heading-2-routing-appget-is-still-appget">2. Routing: <code>app.get</code> is Still <code>app.get</code></h2>
<p>Defining routes in Express is second nature. You use methods like <code>app.get()</code> and <a target="_blank" href="http://app.post"><code>app.post</code></a><code>()</code>. For routing in Shelf, we use the <code>shelf_router</code> package, and you'll be shocked at how similar it is.</p>
<p><code>app.js</code> (Express)</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// GET request</span>
app.get(<span class="hljs-string">'/users'</span>, <span class="hljs-function">(<span class="hljs-params">req, res</span>) =&gt;</span> {
  res.send(<span class="hljs-string">'Fetching all users'</span>);
});

<span class="hljs-comment">// Route with a parameter</span>
app.get(<span class="hljs-string">'/users/:id'</span>, <span class="hljs-function">(<span class="hljs-params">req, res</span>) =&gt;</span> {
  <span class="hljs-keyword">const</span> { id } = req.params;
  res.send(<span class="hljs-string">`Fetching user with ID: <span class="hljs-subst">${id}</span>`</span>);
});
</code></pre>
<p>Now, the Shelf equivalent. We just create a <code>Router</code> instance, which feels a lot like the Express <code>app</code> object.</p>
<p><code>server.dart</code> (Shelf with <code>shelf_router</code>)</p>
<pre><code class="lang-dart"><span class="hljs-keyword">import</span> <span class="hljs-string">'package:shelf_router/shelf_router.dart'</span>;

<span class="hljs-comment">// ... (imports and main function setup)</span>
<span class="hljs-keyword">void</span> main() <span class="hljs-keyword">async</span> {
  <span class="hljs-keyword">final</span> app = Router();

  <span class="hljs-comment">// GET request</span>
  app.<span class="hljs-keyword">get</span>(<span class="hljs-string">'/users'</span>, (Request request) {
    <span class="hljs-keyword">return</span> Response.ok(<span class="hljs-string">'Fetching all users'</span>);
  });

  <span class="hljs-comment">// Route with a parameter - notice the &lt;id&gt; syntax</span>
  app.<span class="hljs-keyword">get</span>(<span class="hljs-string">'/users/&lt;id&gt;'</span>, (Request request, <span class="hljs-built_in">String</span> id) {
    <span class="hljs-keyword">return</span> Response.ok(<span class="hljs-string">'Fetching user with ID: <span class="hljs-subst">$id</span>'</span>);
  });

  <span class="hljs-keyword">await</span> io.serve(app, <span class="hljs-string">'localhost'</span>, <span class="hljs-number">3000</span>); <span class="hljs-comment">// Serve the router</span>
}
</code></pre>
<p>The method is still <code>.get()</code>. The only real difference is the parameter syntax (<code>:id</code> vs. <code>&lt;id&gt;</code>) and how you access it (as a function argument instead of on a <code>params</code> object).</p>
<h2 id="heading-3-middleware-the-concept-is-identical">3. Middleware: The Concept is Identical</h2>
<p>Middleware is the heart of Express, and that concept translates perfectly to Shelf. In Express, you use <code>app.use()</code> to apply middleware to all incoming requests.</p>
<p><code>app.js</code> (Express)</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// A simple logger middleware</span>
<span class="hljs-keyword">const</span> logger = <span class="hljs-function">(<span class="hljs-params">req, res, next</span>) =&gt;</span> {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`<span class="hljs-subst">${req.method}</span> <span class="hljs-subst">${req.originalUrl}</span>`</span>);
  next(); <span class="hljs-comment">// Don't forget to call next()!</span>
};

app.use(logger);
</code></pre>
<p>In Shelf, you use a <code>Pipeline</code> to achieve the same thing. A pipeline lets you "pipe" a request through a series of middleware before it hits your router.</p>
<p><code>server.dart</code> (Shelf)</p>
<pre><code class="lang-dart"><span class="hljs-comment">// A simple logger middleware</span>
Middleware logger = (Handler innerHandler) {
  <span class="hljs-keyword">return</span> (Request request) {
    <span class="hljs-built_in">print</span>(<span class="hljs-string">'<span class="hljs-subst">${request.method}</span> <span class="hljs-subst">${request.url}</span>'</span>);
    <span class="hljs-comment">// The request is automatically passed to the next handler</span>
    <span class="hljs-keyword">return</span> innerHandler(request);
  };
};

<span class="hljs-comment">// ... in main()</span>
<span class="hljs-keyword">final</span> myRouter = Router(); <span class="hljs-comment">// Your router from the example above</span>
<span class="hljs-comment">// ...</span>

<span class="hljs-keyword">final</span> handler = <span class="hljs-keyword">const</span> Pipeline()
    .addMiddleware(logger) <span class="hljs-comment">// This is the Shelf version of app.use()</span>
    .addHandler(myRouter); <span class="hljs-comment">// The final destination for the request</span>

<span class="hljs-keyword">await</span> io.serve(handler, <span class="hljs-string">'localhost'</span>, <span class="hljs-number">3000</span>);
</code></pre>
<h2 id="heading-conclusion-you-already-know-backend-dart">Conclusion: You Already Know Backend Dart</h2>
<p>While the syntax has its own Dart flavor, the fundamental patterns are the same. If you understand how to handle routes and link middleware in Express, you already understand how to do it in Shelf.</p>
<p>By leveraging your existing Express knowledge, the barrier to entry for backend Dart is incredibly low. You get to keep your expert understanding of web concepts while gaining the powerful benefits of Dart, like its excellent type safety and a unified language for both your frontend (Flutter) and backend.</p>
<p>Your Express skills haven't just prepared you for Node.js development; they've given you a head start in the Dart ecosystem, too.</p>
]]></content:encoded></item><item><title><![CDATA[Dart Backend for Node.js Developers]]></title><description><![CDATA[Thinking about Dart for your next project? This guide helps Node.js developers transition by building a simple backend server from scratch.]]></description><link>https://developerjamiu.hashnode.dev/dart-backend-for-nodejs-developers</link><guid isPermaLink="true">https://developerjamiu.hashnode.dev/dart-backend-for-nodejs-developers</guid><category><![CDATA[Dart]]></category><category><![CDATA[backend]]></category><category><![CDATA[Node.js]]></category><dc:creator><![CDATA[Jamiu Okanlawon]]></dc:creator><pubDate>Wed, 28 May 2025 05:57:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1748415433175/66202dc9-20c5-4aa0-84eb-553f9c1541cb.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Dart can be used for backend development just like Node.js, leveraging its built-in <code>dart:io</code> library. If you're a Node.js developer, you'll find many similarities in how Dart handles HTTP servers, with some key differences in syntax and paradigms.</p>
<blockquote>
<p><strong>Disclaimer:</strong> This article focuses on using Dart's built-in <code>dart:io</code> library for HTTP servers, similar to Node.js' built-in <code>http</code> module. A discussion on frameworks like Express.js (Node.js) and Shelf (Dart) will be covered in a separate resource.</p>
</blockquote>
<hr />
<h2 id="heading-prerequisites"><strong>Prerequisites</strong></h2>
<p>Before diving in, ensure you have the following:</p>
<ul>
<li><p>Basic knowledge of Dart and Node.js.</p>
</li>
<li><p><a target="_blank" href="https://dart.dev/get-dart">Dart SDK</a> installed.</p>
</li>
<li><p>A code editor like VS Code or IntelliJ IDEA.</p>
</li>
<li><p>A terminal to run Dart scripts.</p>
</li>
<li><p>Postman (or a browser) for testing API requests.</p>
</li>
</ul>
<hr />
<h2 id="heading-1-setting-up-your-first-dart-http-server"><strong>1. Setting Up Your First Dart HTTP Server</strong></h2>
<h3 id="heading-step-1-create-a-new-dart-file"><strong>Step 1: Create a New Dart File</strong></h3>
<p>Create a new file <code>server.dart</code> in your working directory.</p>
<h3 id="heading-step-2-add-the-following-code"><strong>Step 2: Add the Following Code</strong></h3>
<p>Open <code>server.dart</code> and add this basic HTTP server implementation:</p>
<pre><code class="lang-dart"><span class="hljs-keyword">import</span> <span class="hljs-string">'dart:io'</span>;

<span class="hljs-keyword">void</span> main() <span class="hljs-keyword">async</span> {
  <span class="hljs-keyword">final</span> server = <span class="hljs-keyword">await</span> HttpServer.bind(InternetAddress.loopbackIPv4, <span class="hljs-number">3000</span>);
  <span class="hljs-built_in">print</span>(<span class="hljs-string">'Server running on http://<span class="hljs-subst">${server.address.address}</span>:<span class="hljs-subst">${server.port}</span>'</span>);

  server.listen((HttpRequest request) {
    request.response.statusCode = HttpStatus.ok;
    request.response.headers.contentType = ContentType.html;
    request.response.write(<span class="hljs-string">'&lt;h1&gt;Hello, World!&lt;/h1&gt;'</span>);
    request.response.close();
  });
}
</code></pre>
<h3 id="heading-step-3-running-the-server"><strong>Step 3: Running the Server</strong></h3>
<p>Run the following command in your terminal:</p>
<pre><code class="lang-bash">dart server.dart
</code></pre>
<p>(This is similar to running <code>node app.js</code> in Node.js.)</p>
<h3 id="heading-step-4-testing-the-server"><strong>Step 4: Testing the Server</strong></h3>
<p>Open your browser and go to <code>http://localhost:3000/</code> or use Postman to send a GET request.</p>
<h3 id="heading-step-5-using-the-cascading-approach-shortened-code"><strong>Step 5: Using the Cascading Approach (Shortened Code)</strong></h3>
<p>We can rewrite the response handling more concisely using the cascade notation:</p>
<pre><code class="lang-dart">server.listen((HttpRequest request) {
  request.response
    ..statusCode = HttpStatus.ok
    ..headers.contentType = ContentType.html
    ..write(<span class="hljs-string">'&lt;h1&gt;Hello, World!&lt;/h1&gt;'</span>)
    ..close();
});
</code></pre>
<hr />
<h2 id="heading-2-handling-routes-and-http-methods"><strong>2. Handling Routes and HTTP Methods</strong></h2>
<p>Let's extend our server to handle multiple routes and HTTP methods.</p>
<h3 id="heading-handling-different-routes-and-methods"><strong>Handling Different Routes and Methods</strong></h3>
<pre><code class="lang-bash">void main() async {
  final server = await HttpServer.bind(InternetAddress.loopbackIPv4, 3000);
  <span class="hljs-built_in">print</span>(<span class="hljs-string">'Server running on http://${server.address.address}:${server.port}'</span>);

  server.listen((HttpRequest request) {
    <span class="hljs-keyword">if</span> (request.uri.path == <span class="hljs-string">'/'</span> &amp;&amp; request.method == <span class="hljs-string">'GET'</span>) {
      request.response
        ..headers.contentType = ContentType.html
        ..write(<span class="hljs-string">'&lt;h1&gt;Welcome to Dart vs Node.js&lt;/h1&gt;'</span>)
        ..close();
    } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (request.uri.path == <span class="hljs-string">'/data'</span> &amp;&amp; request.method == <span class="hljs-string">'POST'</span>) {
      request.response
        ..statusCode = HttpStatus.created
        ..write(<span class="hljs-string">'Data received'</span>)
        ..close();
    } <span class="hljs-keyword">else</span> {
      request.response
        ..statusCode = HttpStatus.notFound
        ..write(<span class="hljs-string">'404 Not Found'</span>)
        ..close();
    }
  });
}
</code></pre>
<hr />
<h2 id="heading-3-assignment"><strong>3. Assignment</strong></h2>
<p>Modify the Dart code to:</p>
<ul>
<li><p>Add more routes (e.g., <code>/users</code>, <code>/products</code>).</p>
</li>
<li><p>Handle more HTTP verbs (<code>PUT</code>, <code>DELETE</code>).</p>
</li>
<li><p>Respond with JSON data for certain routes.</p>
</li>
</ul>
<p>Example JSON response:</p>
<pre><code class="lang-bash">request.response
  ..headers.contentType = ContentType.json
  ..write(<span class="hljs-string">'{"message": "User added successfully"}'</span>)
  ..close();
</code></pre>
<hr />
<h2 id="heading-4-next-steps-exploring-frameworks"><strong>4. Next Steps: Exploring Frameworks</strong></h2>
<p>While <code>dart:io</code> provides a low-level approach, frameworks like <strong>Shelf (Dart)</strong> and <strong>Express.js (Node.js)</strong> simplify development by adding routing, middleware, and request handling.</p>
<p>For those who have experience with Express.js, Dart's Shelf framework uses very similar patterns for routing and middleware.</p>
<p>To see how those skills overlap, consider reading <a target="_blank" href="https://developerjamiu.hashnode.dev/dart-shelf-for-expressjs-developers"><strong>Dart Shelf for Express.js Developers</strong></a><strong>.</strong></p>
<hr />
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<ul>
<li><p><strong>Dart and Node.js provide built-in HTTP modules</strong>, making backend development possible without external dependencies.</p>
</li>
<li><p><strong>Dart’s syntax is more structured</strong> with <code>await for</code> loops and cascade notation (<code>..</code>), but cascading is optional.</p>
</li>
<li><p><strong>Both platforms use event-driven programming</strong>, but Dart offers <code>Isolates</code> for concurrency.</p>
</li>
<li><p><strong>For complex backends</strong>, frameworks like <strong>Shelf (Dart)</strong> and <strong>Express.js (Node.js)</strong> can simplify development.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Deploying a DartFrog Backend App Using Globe]]></title><description><![CDATA[As backend developers, we often start by building and testing our APIs locally. Everything works perfectly on our machine until we want to make the APIs…]]></description><link>https://developerjamiu.hashnode.dev/deploying-a-dartfrog-backend-app-using-globe</link><guid isPermaLink="true">https://developerjamiu.hashnode.dev/deploying-a-dartfrog-backend-app-using-globe</guid><category><![CDATA[Dart]]></category><category><![CDATA[dart_frog]]></category><category><![CDATA[backend]]></category><category><![CDATA[deployment]]></category><category><![CDATA[globe]]></category><dc:creator><![CDATA[Jamiu Okanlawon]]></dc:creator><pubDate>Sun, 12 Jan 2025 19:52:31 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1736619448457/44b5e105-d809-4648-b87f-e6b853c315c0.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>As backend developers, we often start by building and testing our APIs locally. Everything works perfectly on our machine until we want to make the APIs accessible to everyone on the internet.</p>
<p>While numerous deployment platforms exist, finding one that works seamlessly with Dart can be challenging. <a target="_blank" href="https://globe.dev/">Globe</a> offers a straightforward path to deploying our Dart backends.</p>
<p>In this article, we will walk through deploying a simple todo API built with <a target="_blank" href="https://dartfrog.vgv.dev/">Dart Frog</a> on Globe. With that in mind, you’ll get the most out of this article if you:</p>
<ul>
<li><p>Have worked with Dart in any capacity, either as a Flutter developer or just with Dart</p>
</li>
<li><p>Are interested in exploring what's new in deployment platforms</p>
</li>
<li><p>Are curious about the latest and greatest ways of getting your Dart backend APIs accessible to everyone</p>
</li>
<li><p>Are looking to learn something new about modern backend deployment</p>
</li>
</ul>
<hr />
<h2 id="heading-why-choose-globe-for-deployment"><strong>Why choose Globe for deployment?</strong></h2>
<p><a target="_blank" href="https://globe.dev/">Globe</a> is purpose-built to streamline backend hosting for Dart and Flutter developers. Here's why it was the platform of choice for this deployment:</p>
<ul>
<li><p><strong>Tailored for Dart and Flutter</strong>: Globe seamlessly integrates with frameworks like DartFrog, offering a native experience for Dart developers.</p>
</li>
<li><p><strong>Intuitive and developer-friendly</strong>: With clear documentation and simple CLI tools, Globe makes it easy to set up and deploy your application.</p>
</li>
<li><p><strong>Efficient deployment workflow</strong>: It provides essential features like environment variable management, GitHub integration, and a straightforward path to production.</p>
</li>
</ul>
<p>By leveraging Globe, you can save time and focus more on building your application rather than managing deployment complexities.</p>
<hr />
<h2 id="heading-setting-up-the-application-locally">Setting up the application locally</h2>
<p>For this guide, we’ll deploy a simple Todo API built with DartFrog, a lightweight and efficient framework for Dart developers. The project demonstrates the basics of managing Todos with an in-memory storage setup, keeping things straightforward for this tutorial. The source code is publicly available, so you can follow along. You can find the project repository here: <a target="_blank" href="https://github.com/developerjamiu/todo_backend">GitHub Repo</a>.</p>
<p>Before diving into deployment, let’s first verify the app runs correctly on your local machine.</p>
<ol>
<li><p><strong>Clone the Repository</strong>:</p>
<pre><code class="lang-bash"> git <span class="hljs-built_in">clone</span> git@github.com:developerjamiu/todo_backend.git
</code></pre>
</li>
<li><p><strong>Open the Project</strong>: Open the cloned folder in your preferred IDE.</p>
</li>
<li><p><strong>Fetch Dependencies</strong>: Run the following command to retrieve the necessary dependencies:</p>
<pre><code class="lang-bash"> flutter pub get
</code></pre>
</li>
</ol>
<hr />
<h2 id="heading-testing-the-backend-app-locally">Testing the backend app locally</h2>
<p>Now that you’ve cloned the project, let’s run the DartFrog project to ensure everything works as expected:</p>
<ol>
<li><p><strong>Install DartFrog CLI</strong>: Install the DartFrog CLI using the following command:</p>
<pre><code class="lang-bash"> dart pub global activate dart_frog_cli
</code></pre>
<blockquote>
<p><strong>Quick Tip</strong>: If you run into issues with dart_frog dev not being recognised, check your Dart SDK configuration. You can use the SDK that comes with Flutter (usually found in bin/cache/dart-sdk) if needed.</p>
</blockquote>
</li>
<li><p><strong>Start the Development Server</strong>: Launch the server with:</p>
<pre><code class="lang-bash"> dart_frog dev
</code></pre>
<p> You should see:</p>
<pre><code class="lang-plaintext"> Running on http://localhost:8080
</code></pre>
<p> By default, DartFrog uses port 8080. The backend app exposes the following endpoints:</p>
<ul>
<li><p><code>GET /todos</code> – Retrieves all Todos</p>
</li>
<li><p><code>POST /todos</code> – Adds a new Todo</p>
</li>
<li><p><code>GET /todos/:id</code> – Retrieves a specific Todo by ID</p>
</li>
<li><p><code>PUT /todos/:id</code> – Updates a specific Todo by ID</p>
</li>
<li><p><code>DELETE /todos/:id</code> – Deletes a specific Todo by ID</p>
</li>
</ul>
</li>
<li><p><strong>Test the Endpoints</strong>:</p>
<p> Let’s test these endpoints using <strong>curl</strong>.</p>
<ul>
<li><h4 id="heading-get-all-todos-get"><strong>Get All Todos (GET)</strong></h4>
<p>  Run the following in your terminal to fetch all the Todos (which should be empty initially):</p>
</li>
<li><pre><code class="lang-bash">  curl --request GET --url http://localhost:8080/todos
</code></pre>
</li>
<li><h4 id="heading-add-a-todo-post"><strong>Add a Todo (POST)</strong></h4>
<p>  Add a new Todo with the following command:</p>
<pre><code class="lang-bash">  curl --request POST --url http://localhost:8080/todos --data <span class="hljs-string">'{"name": "Task 1"}'</span>
</code></pre>
<p>  You should see the added Todo in the response.</p>
</li>
<li><h4 id="heading-verify-the-added-todo"><strong>Verify the Added Todo</strong></h4>
<p>  Now, verify the Todo was added successfully by fetching all Todos again:</p>
</li>
<li><pre><code class="lang-bash">  curl --request GET --url http://localhost:8080/todos
</code></pre>
</li>
<li><h4 id="heading-update-a-todo-put"><strong>Update a Todo (PUT)</strong></h4>
<p>  Use the <strong>PUT</strong> method to update an existing Todo. Replace <code>1</code> with the ID of the Todo you want to update.</p>
</li>
<li><pre><code class="lang-bash">  curl --request PUT --url http://localhost:8080/todos/1 --data <span class="hljs-string">'{"name": "Updated Task", "completed": true}'</span>
</code></pre>
</li>
<li><h4 id="heading-get-one-todo-get-by-id"><strong>Get One Todo (GET by ID)</strong></h4>
<p>  To fetch a specific Todo by its ID. Replace <code>1</code> with the ID of the Todo you want to update.</p>
</li>
<li><pre><code class="lang-bash">  curl --request GET --url http://localhost:8080/todos/1
</code></pre>
</li>
<li><h4 id="heading-delete-a-todo-delete"><strong>Delete a Todo (DELETE)</strong></h4>
<p>  To delete a specific Todo by ID. Replace <code>1</code> with the ID of the Todo you want to update.</p>
</li>
<li><pre><code class="lang-bash">  curl --request DELETE --url http://localhost:8080/todos/1
</code></pre>
</li>
</ul>
</li>
</ol>
<hr />
<h2 id="heading-deploying-the-application-using-globe">Deploying the application using Globe</h2>
<p>With the backend app functioning locally, let's deploy it using Globe.</p>
<ol>
<li><p><strong>Create a Globe Account</strong>: Visit <a target="_blank" href="https://globe.dev">Globe.dev</a> and sign up for a free account. Once logged in, you'll access the Globe dashboard.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736619731891/ac2b07e0-23d2-4a5b-bf30-5a58be40892f.png" alt class="image--center mx-auto" /></p>
</li>
<li><p><strong>Login via Globe CLI</strong>: In your terminal, execute:</p>
<pre><code class="lang-bash"> globe login
</code></pre>
<p> Follow the prompts to authenticate your account.</p>
</li>
<li><p><strong>Deploy the Application</strong>: Navigate to your project directory and run:</p>
<pre><code class="lang-bash"> globe deploy
</code></pre>
<p> Respond to the prompts or accept the default values. After deployment, your project will appear in the Globe dashboard.</p>
</li>
</ol>
<hr />
<h2 id="heading-troubleshooting">Troubleshooting</h2>
<p>Here are common issues and their solutions:</p>
<ol>
<li><p><strong>Validation Error</strong>: You might encounter the following validation error:</p>
<pre><code class="lang-bash"> Globe API Error: Entrypoint must be a valid Dart file.
</code></pre>
<p> <strong>Solution</strong>: Re-run <code>globe deploy</code> and select the initial project name to link the project properly.</p>
</li>
<li><p><strong>Deployment Failed</strong>: If deployment fails, access the Globe dashboard, navigate to your project settings, and:</p>
<ul>
<li><p>Change the <strong>Framework Preset</strong> to <strong>DartFrog</strong>.</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1736619702513/b2827a6c-dff6-4584-980e-3fc51314bb70.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Save the settings. Then re-run:</p>
<pre><code class="lang-bash">  globe deploy
</code></pre>
</li>
</ul>
</li>
</ol>
<hr />
<h2 id="heading-testing-the-deployed-backend-app">Testing the deployed backend app</h2>
<p>Upon successful deployment, you'll receive a deployment URL. Replace <code>localhost:8080</code> in your previous <code>curl</code> commands with this URL to verify the endpoints.</p>
<p>To make a production deployment, execute:</p>
<pre><code class="lang-bash">globe deploy --prod
</code></pre>
<p>A production URL will be generated for sharing.</p>
<hr />
<h2 id="heading-additional-features-in-globe">Additional features in Globe</h2>
<p>Explore Globe's features, including:</p>
<ul>
<li><p>Setting up <a target="_blank" href="https://docs.globe.dev/deployments/environment-variables">environment variables</a>.</p>
</li>
<li><p><a target="_blank" href="https://docs.globe.dev/deployments/github-integration">Connecting your GitHub repository</a> for automatic deployments on code changes.</p>
</li>
</ul>
<p>For comprehensive information, visit the <a target="_blank" href="https://docs.globe.dev/">Globe Documentation</a>.</p>
<hr />
<h2 id="heading-final-thoughts">Final thoughts</h2>
<p>If you're new to backend development, consider starting with foundational concepts before diving into DartFrog. Refer to the <a target="_blank" href="https://dartfrog.vgv.dev/docs/overview">DartFrog documentation</a> for guidance.</p>
<p>Deploying a DartFrog application using Globe is straightforward, and I hope this guide assists you in your deployment journey. For a practical example, check out my implementation on <a target="_blank" href="https://github.com/developerjamiu/todo_backend">GitHub</a>.</p>
]]></content:encoded></item></channel></rss>