DEV Community

David Ongora
David Ongora

Posted on

Deploy Flutter Web App to Vercel

Deploying a Flutter web app to Vercel is a straightforward process that allows you to host your app with ease. Vercel is a popular platform for deploying web applications, and it provides a seamless experience for hosting Flutter web apps. In this guide, we'll walk you through the steps to deploy your Flutter web app to Vercel.

sample flutter app deployed you can clone it and deploy it
https://notes-whiz-14l2.vercel.app/

github link https://github.com/davidongora/NotesWhiz

Prerequisites
Before you begin, ensure you have the following:

A Flutter web app ready for deployment.

  • A Vercel account (sign up at vercel.com).
  • Git installed on your machine.
  • Flutter SDK installed and configured.

Step 1: Prepare Your Flutter Web App

Ensure your Flutter app is configured for web deployment.

Enable Web Support:
Run the following command to enable web support in your Flutter project:

flutter config --enable-web
Enter fullscreen mode Exit fullscreen mode

Build for Web:
Build your Flutter app for the web:

flutter build web
Enter fullscreen mode Exit fullscreen mode

Step 2: Push Your Code to GitHub

Step 3: Deploy to Vercel
Now that your code is on GitHub, you can deploy it to Vercel.

Log in to Vercel:
Go to vercel.com and log in with your GitHub account.

Create a New Project:

Click on the "New Project" button.

Select the GitHub repository where your Flutter app is hosted.

Configure the Build Settings:

Vercel will automatically detect your Flutter project.

Set the following build settings:

Build Command:

flutter/bin/flutter build web --release
Enter fullscreen mode Exit fullscreen mode

Output Directory:

build/web
Enter fullscreen mode Exit fullscreen mode

Install Command:

if cd flutter; then git pull && cd .. ; else git clone https://github.com/flutter/flutter.git; fi && ls && flutter/bin/flutter doctor && flutter/bin/flutter clean && flutter/bin/flutter config --enable-web
Enter fullscreen mode Exit fullscreen mode

Deploy:

Click the "Deploy" button.

Vercel will start building your Flutter web app. This process may take a few minutes.

Step 4: Access Your Deployed Site
Once the build is complete, Vercel will provide you with a live URL for your deployed Flutter web app. You can access your app by clicking the link provided in the Vercel dashboard.

Step 5: Custom Domain (Optional)
If you want to use a custom domain for your Flutter web app:

Go to the "Domains" section in your Vercel dashboard.

Add your custom domain and follow the instructions to configure DNS settings.

Troubleshooting
If you encounter issues during deployment, check the following:

Flutter Web Compatibility:
Ensure your app and its dependencies are compatible with the web platform. Avoid using libraries like dart:ffi that are not supported on the web.

Build Logs:
Check the build logs in the Vercel dashboard for detailed error messages.

Flutter Version:
Ensure you're using a stable version of Flutter. Run flutter upgrade to update your Flutter SDK.

Deploying a Flutter web app to Vercel is a quick and efficient way to host your app. By following the steps outlined in this guide, you can easily deploy your Flutter web app and share it with the world. Happy coding! 🚀

Top comments (0)