This template provides a solid foundation for building full-stack applications with Flutter for the frontend, Express for the backend, and Supabase for authentication, database, and storage.
- Flutter for a responsive and modern mobile/web frontend
- Express backend for robust API handling
- Supabase integration for secure data operations
- CORS enabled for cross-origin API calls
- Environment-based configuration with a
.env.localfile - Modular project structure for scalable development
- Node.js 18.17 or later
- npm (or yarn / pnpm)
- Flutter (stable channel, version 3.x or later)
- Supabase account (free tier available)
git clone https://github.com/Codelab-Davis/flutter-express-supabase.git my-app
cd my-app- Create a new project at supabase.com
- Copy your project URL and service (or anon) key from the API settings
- Create a
.env.localfile in the backend directory with the following content:
SUPABASE_URL=YOUR_SUPABASE_URL
SUPABASE_KEY=YOUR_SUPABASE_KEY
- Navigate to the backend directory:
cd backend- Install dependencies:
npm install- Run the Express server:
npm startOpen http://localhost:3000 with your browser to see the health check message.
- Navigate to the Flutter app directory from the backend:
cd ../flutter_app- Install Flutter dependencies:
flutter pub get- Run the Flutter app in development mode:
flutter runThe Flutter app will launch on your connected device or emulator.
/my-app
├── backend/ # Express backend
│ ├── node_modules/
│ ├── .env.local # Environment variables for Supabase
│ ├── server.js # Main Express server file
│ └── ... # Other backend files and directories
└── flutter_app/ # Flutter frontend
├── lib/ # Dart source files
├── android/ # Android-specific files
├── ios/ # iOS-specific files
└── ... # Other Flutter files and directories
This template uses Express to create API endpoints and interact with Supabase.
// backend/server.js
app.get('/api/health', (req, res) => {
res.json({ message: 'Express server is healthy' });
});The Flutter frontend communicates with the Express backend via HTTP API calls. Use packages like http or dio for API integration.
import 'package:http/http.dart' as http;
Future<void> fetchHealth() async {
final response = await http.get(Uri.parse('http://localhost:3000/api/health'));
if (response.statusCode == 200) {
print('Server is healthy');
} else {
print('Error: ${response.statusCode}');
}
}The Express backend integrates with Supabase using the Supabase client. Use your keys from .env.local to initialize the client:
// backend/server.js
const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_KEY);Utilize this client within your routes to perform authentication, database operations, and file storage tasks.
For the Express backend:
# Lint code
npm run lint
# Format code
npm run formatFor the Flutter frontend:
flutter analyze
dart format .Deploy your Express backend to platforms like Heroku, Vercel (using serverless functions), or any Node.js hosting provider.
For mobile deployment, follow the official Flutter deployment guides.
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request