Skip to content

FlutterJS: Compile Flutter to semantic HTML. Get 100/100 SEO scores with Flutter's developer experience.

License

Notifications You must be signed in to change notification settings

flutterjsdev/flutterjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

341 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

FlutterJS

Same Flutter Code. Real HTML Output.

For when your Flutter app needs to be found by Google.

🌐 flutterjs.dev

Installation β€’ Quick Start β€’ Why FlutterJS? β€’ Documentation


The Problem

Flutter Web is amazing for apps, but terrible for the web:

Flutter Web Issue Impact
πŸ“¦ 2-5+ MB bundle Slow initial load, especially on mobile
πŸ” Zero SEO Canvas rendering = invisible to Google
β™Ώ Poor accessibility No semantic HTML for screen readers
🐒 Slow first paint WASM/CanvasKit takes time to initialize

Your beautiful Flutter app is invisible to search engines.

The Solution

FlutterJS compiles your Flutter/Dart code to semantic HTML + CSS + JavaScript instead of Canvas/WASM.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  YOUR FLUTTER CODE                       β”‚
β”‚                                                         β”‚
β”‚   Scaffold(                                             β”‚
β”‚     appBar: AppBar(title: Text('My App')),              β”‚
β”‚     body: Center(child: Text('Hello World')),           β”‚
β”‚   )                                                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β–Ό                               β–Ό
   Flutter Web                      FlutterJS
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚ <canvas>    β”‚               β”‚ <header>    β”‚
   β”‚ (pixels)    β”‚               β”‚ <main>      β”‚
   β”‚ 5 MB        β”‚               β”‚ <h1>        β”‚
   β”‚ No SEO      β”‚               β”‚ 50 KB       β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚ Full SEO βœ“  β”‚
                                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Why FlutterJS?

Feature Flutter Web FlutterJS
Code Syntax Flutter/Dart Flutter/Dart βœ“
Bundle Size 2-5 MB ~50-100 KB
SEO ❌ None βœ“ Full
Google Indexable ❌ No βœ“ Yes
Accessibility Poor Good
Initial Load 3-8 seconds <1 second
SSR Support ❌ No βœ“ Yes
Output Canvas pixels Real HTML

Installation

System Requirements

To develop with or use FlutterJS, you need:

  • Dart SDK: ^3.10.0 or higher (Stable).
  • Node.js: Required for the JavaScript engine and CLI tools.
  • NPM: Package manager for JS dependencies.
  • Git: For managing the monorepo and submodules.
  • Flutter SDK: (Optional but recommended) For resolving SDK dependencies.

Option 1: npm (Recommended for users)

npm install -g flutterjs

Option 2: From Source (For contributors)

git clone --recursive https://github.com/flutterjsdev/flutterjs.git
cd flutterjs
dart pub global activate --source path .
dart pub get
dart run tool/init.dart

Current Status & Progress

βœ… CI/CD Stabilized: Full automation with GitHub Actions, supporting recursive submodules and workspace resolution. βœ… Ecosystem Launch: First official package flutterjs_seo is now live on pub.dev. βœ… Modern Dart Support: Fully compatible with Dart 3.10+ features including dot shorthand and records. βœ… Monorepo Readiness: Standardized workspace structure across all 20+ packages.


Quick Start

1. Create a New Project

flutter create my-app
cd my-app

2. Write Flutter Code

// src/main.dart
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('FlutterJS App')),
        body: Center(
          child: Text('Hello from FlutterJS!'),
        ),
      ),
    );
  }
}

3. Run Development Server

flutterjs run --to-js --serve

Open http://localhost:3000 β€” inspect the page to see real HTML elements, not canvas!

4. Build for Production

# Build your application
flutterjs build

This creates a dist/ directory with:

  • index.html (Entry point)
  • assets/ (Static resources)
  • main.js (Compiled app)
  • vercel.json (Deployment config)

5. Deploy to Vercel

Since flutterjs build automatically generates vercel.json, deployment is zero-config:

# Using Vercel CLI
vercel deploy

Or connect your GitHub repository to Vercelβ€”it will automatically detect the output.


Deployment

Vercel (Recommended)

Deployment is zero-config and optimized for cleanliness (no duplicate node_modules).

  1. Build:

    flutterjs build

    (Creates dist/ with app files, keeps dependencies in root)

  2. Deploy:

    cd ./build/flutterjs
    vercel deploy --prod

The build automatically generates vercel.json and .vercelignore to ensure:

  • Routing: SPAs work correctly (all routes β†’ index.html)
  • Dependencies: node_modules are uploaded efficiently
  • Cleanliness: Your project remains unpolluted

Other Providers

You can deploy the contents of build/flutterjs/dist/ to any static host (Netlify, GitHub Pages, Firebase Hosting). Note: Ensure your provider handles SPA routing (redirect 404s to index.html).


How It Works

FlutterJS intercepts kIsWeb platform checks and routes web-specific code through a lightweight JavaScript runtime instead of Flutter's Canvas/WASM engine.

// Your existing Flutter code
if (kIsWeb) {
  // FlutterJS handles this path
  // Converts to semantic HTML + CSS
}

Architecture

Flutter/Dart Source
        β”‚
        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  FlutterJS Parser β”‚  ← Analyzes Dart AST
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚
          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Code Generator  β”‚  ← Transforms to JavaScript
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚
          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   JS Runtime      β”‚  ← VNode/VDOM engine
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚
          β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   HTML + CSS      β”‚  ← Semantic, SEO-friendly output
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

CLI Commands

Command Description
flutterjs init <name> Create new project
flutterjs dev Start dev server with hot reload
flutterjs build Production build with minification
flutterjs preview Preview production build
flutterjs --help Show all commands

Build Options

flutterjs build --mode ssr         # Server-side rendering
flutterjs build --mode csr         # Client-side rendering (default)
flutterjs build --mode hybrid      # Best of both
flutterjs build -O 0               # Debug build (No optimization / No minification)
flutterjs build -O 3               # Production build (Aggressive optimization)
flutterjs build --output ./dist    # Custom output directory

Render Modes

CSR (Client-Side Rendering) β€” Default

Application renders in the browser. Good for SPAs.

CSR (Client-Side Rendering) β€” Default

Application renders entirely in the browser using JavaScript.

  • Best for: Dynamic web apps, Dashboards, Admin panels.
  • CLI: flutterjs run --target spa (or just flutterjs run)
  • Config: mode: 'csr'

SSR (Server-Side Rendering)

Pre-renders HTML on the server (build time) and hydrates on the client.

  • Best for: Marketing sites, Blogs, SEO-critical content.
  • CLI: flutterjs run --target ssr
  • Config: mode: 'ssr'
  • How it works:
    1. Build generates a pre-rendered index.html.
    2. Client downloads HTML (instant paint).
    3. Client hydrates (attaches event listeners).

Hybrid (Coming Soon)

A mix of Static Site Generation (SSG) and SPA.

  • Best for: Large sites with mixed content.
  • CLI: flutterjs run --target hybrid
  • Config: mode: 'hybrid'
  • Note: Currently experimental. Use SSR for best SEO results.

Supported Widgets

FlutterJS supports the most commonly used Flutter widgets:

Layout

  • Container, Center, Padding, SizedBox
  • Row, Column, Stack, Positioned
  • Expanded, Flexible, Spacer

Material

  • Scaffold, AppBar, Drawer
  • ElevatedButton, TextButton, IconButton, FloatingActionButton
  • Text, Icon, Image
  • Card, Divider
  • TextField, Checkbox, Switch

Navigation

  • Navigator, MaterialPageRoute

State Management

  • StatefulWidget, setState()
  • InheritedWidget

More widgets are being added regularly.


Who Should Use FlutterJS?

βœ… Use FlutterJS if:

  • Your Flutter app needs SEO (blogs, e-commerce, marketing sites)
  • You're targeting low-bandwidth users (smaller bundles matter)
  • You need Google to index your content
  • You want semantic HTML for accessibility
  • First-load performance is critical

❌ Stick with Flutter Web if:

  • You're building a complex app (games, graphics-heavy)
  • SEO doesn't matter (internal tools, dashboards)
  • You need every Flutter widget/feature

Performance

Metric Flutter Web FlutterJS
Bundle Size 2-5 MB ~50-100 KB
First Paint 3-8s <1s
Time to Interactive 5-10s <2s
Lighthouse SEO 0-30 90-100

Configuration

Create flutterjs.config.js in your project root:

module.exports = {
  // Rendering mode
  mode: 'csr', // 'ssr' | 'csr' | 'hybrid'
  
  // Build settings
  build: {
    output: 'dist',
    minify: true,
    sourcemap: false,
  },
  
  // Dev server
  server: {
    port: 3000,
    hot: true,
  },
  
  // Optimization
  optimization: {
    treeshake: true,
    splitChunks: true,
  }
};

Project Structure

my-app/
β”œβ”€β”€ flutter.config.js      # Configuration
β”œβ”€β”€ package.json
β”œβ”€β”€ src/
β”‚   └── main.dart          # Your Flutter code
β”œβ”€β”€ assets/                # Static files (images, fonts)
β”œβ”€β”€ .flutter_js/           # Generated code (auto)
└── dist/                  # Production build (generated)

Dart CLI Pipeline

FlutterJS includes a powerful Dart CLI that analyzes your Flutter/Dart code and converts it to optimized JavaScript.

Running the Dart CLI

# Navigate to your Flutter project
cd examples/counter

# Run the full pipeline: Analysis β†’ IR β†’ JavaScript
dart run path/to/flutterjs/bin/flutterjs.dart run --to-js

# With dev server (starts after conversion)
dart run path/to/flutterjs/bin/flutterjs.dart run --to-js --serve

# With custom port
dart run path/to/flutterjs/bin/flutterjs.dart run --to-js --serve --server-port 4000

Pipeline Phases

The Dart CLI executes a multi-phase pipeline:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  PHASE 0: Setup & Initialization                                β”‚
β”‚  β€’ Validate project directory                                   β”‚
β”‚  β€’ Initialize Dart analyzer                                     β”‚
β”‚  β€’ Create output directories                                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  PHASE 1: Static Analysis                                       β”‚
β”‚  β€’ Parse Dart AST                                               β”‚
β”‚  β€’ Build dependency graph                                       β”‚
β”‚  β€’ Detect changed files (incremental)                           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  PHASE 2: IR Generation (5 Passes)                              β”‚
β”‚  β€’ Pass 1: Declaration Discovery                                β”‚
β”‚  β€’ Pass 2: Symbol Resolution                                    β”‚
β”‚  β€’ Pass 3: Type Inference                                       β”‚
β”‚  β€’ Pass 4: Control-Flow Analysis                                β”‚
β”‚  β€’ Pass 5: Validation & Diagnostics                             β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  PHASE 3: IR Serialization                                      β”‚
β”‚  β€’ Generate binary IR files                                     β”‚
β”‚  β€’ Save conversion reports                                      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  PHASE 4-6: JavaScript Conversion                               β”‚
β”‚  β€’ Convert IR to JavaScript                                     β”‚
β”‚  β€’ Validate generated code                                      β”‚
β”‚  β€’ Optimize (levels 0-3)                                        β”‚
β”‚  β€’ Write .fjs files                                             β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  PHASE 7: Dev Server (--serve flag)                             β”‚
β”‚  β€’ Spawn flutterjs.exe dev server                              β”‚
β”‚  β€’ Open browser automatically                                   β”‚
β”‚  β€’ Hot reload on file changes                                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

CLI Options

Flag Description Default
--project, -p Path to Flutter project root .
--source, -s Source directory relative to project lib
--to-js Convert IR to JavaScript false
--serve Start dev server after conversion false
--server-port Dev server port 3000
--open-browser Open browser automatically true
--js-optimization-level Optimization level (0-3) 1
--validate-output Validate generated JavaScript true
--incremental Only reprocess changed files true
--parallel Enable parallel processing true
--verbose, -v Show detailed logs false

Engine Bridge Architecture

FlutterJS uses a bridge architecture to connect the Dart CLI with the JavaScript runtime engine.

Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Dart CLI (flutterjs.dart)                                      β”‚
β”‚                                                                 β”‚
β”‚  β€’ Analyzes Dart/Flutter code                                   β”‚
β”‚  β€’ Generates IR (Intermediate Representation)                   β”‚
β”‚  β€’ Converts IR to .fjs JavaScript files                         β”‚
β”‚                                                                 β”‚
β”‚  After conversion (when --serve is used):                       β”‚
β”‚                     β”‚                                           β”‚
β”‚                     β–Ό Process.start()                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚  flutterjs.exe dev --port 3000                          β”‚   β”‚
β”‚  β”‚                                                          β”‚   β”‚
β”‚  β”‚  β€’ Serves .fjs files via Express.js                      β”‚   β”‚
β”‚  β”‚  β€’ Hot Module Replacement (HMR)                          β”‚   β”‚
β”‚  β”‚  β€’ WebSocket for live updates                            β”‚   β”‚
β”‚  β”‚  β€’ Opens browser automatically                           β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”‚                     β”‚                                           β”‚
β”‚                     β–Ό                                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚  Browser: http://localhost:3000                          β”‚   β”‚
β”‚  β”‚                                                          β”‚   β”‚
β”‚  β”‚  β€’ FlutterJS Runtime loads                               β”‚   β”‚
β”‚  β”‚  β€’ Widgets render to semantic HTML                       β”‚   β”‚
β”‚  β”‚  β€’ State management works                                β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Platform Binaries

The engine bridge automatically detects your platform and uses the appropriate binary:

Platform Binary
Windows flutterjs.exe
macOS flutterjs-macos
Linux flutterjs-linux

Binaries are located in: packages/flutterjs_engine/dist/

Building Engine Binaries

cd packages/flutterjs_engine

# Build for current platform
npm run build:windows  # Windows
npm run build:macos    # macOS
npm run build:linux    # Linux

# Build for all platforms
npm run build:all

Future: IPC Mode (Coming Soon)

The bridge is designed to evolve to a full IPC (Inter-Process Communication) mode:

// Future IPC implementation
Process.start('flutterjs.exe', ['dev', '--ipc']);
// stdin:  {"method": "reload", "files": ["main.fjs"]}
// stdout: {"status": "ok", "reloadedCount": 1}

βœ… Unified Project Structure

The Dart CLI now automatically generates a proper JS project structure in build/flutterjs/:

your-flutter-project/
β”œβ”€β”€ lib/
β”‚   └── main.dart              ← Your Flutter/Dart source code
β”‚
└── build/
    β”œβ”€β”€ reports/               ← Dart CLI reports (analysis, conversion)
    β”‚   β”œβ”€β”€ conversion_report.json
    β”‚   └── summary_report.json
    β”‚
    └── flutterjs/             ← Generated JS project (where JS CLI runs)
        β”œβ”€β”€ flutterjs.config.js  ← Auto-generated config
        β”œβ”€β”€ package.json         ← Auto-generated manifest
        β”œβ”€β”€ src/                 ← Generated .fjs files
        β”‚   └── main.fjs
        └── public/              ← Generated HTML
            └── index.html

How It Works:

  1. Dart CLI runs from your project root (examples/counter)
  2. Dart CLI analyzes lib/main.dart and converts it to build/flutterjs/src/main.fjs
  3. Dart CLI auto-generates flutterjs.config.js, package.json, and public/index.html
  4. JS CLI runs from build/flutterjs/ (the generated JS project)
  5. Browser opens and your app is running!

Example: Counter App

1. Navigate to the example

cd examples/counter

2. Run the full pipeline with dev server

dart run ../../bin/flutterjs.dart run --to-js --serve

3. Output

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    FLUTTER IR TO JAVASCRIPT CONVERSION PIPELINE (Phases 0-6)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Project:  C:\path\to\flutterjs\examples\counter
Source:   C:\path\to\flutterjs\examples\counter\lib
Build:    C:\path\to\flutterjs\examples\counter\build\flutterjs

PHASE 1: Analyzing project...
  Files for conversion: 2

PHASE 2: Generating IR...
  βœ… main.dart processed

PHASES 4-6: Converting IR to JavaScript...
  βœ… Generated: 1 files

οΏ½ Setting up FlutterJS project...
   βœ… JS project initialized

οΏ½πŸš€ Starting FlutterJS Dev Server...
βœ… Dev Server running at http://localhost:3000
   πŸ“ Project root: C:\path\to\flutterjs\examples\counter\build\flutterjs
   πŸ“ Source files: C:\path\to\flutterjs\examples\counter\build\flutterjs\src

⏳ Server(s) running. Press "q" or Ctrl+C to stop.
   🌐 Dev Server: http://localhost:3000

Roadmap

  • Core widget system (StatelessWidget, StatefulWidget)
  • Material Design components
  • CLI with dev server
  • SSR/CSR/Hybrid modes
  • Dart CLI Pipeline (Analysis β†’ IR β†’ JS)
  • Engine Bridge (Dart CLI ↔ JS Runtime)
  • Incremental compilation
  • DevTools IR Viewer
  • Dart Core Libraries (dart:math, dart:async, dart:convert, etc.)
  • Animation support
  • Full Material 3 theming
  • Route-based code splitting
  • PWA support
  • TypeScript definitions
  • IPC mode for tighter CLI-Engine integration

Known Limitations

Method Tear-offs (Callback Context)

Currently, passing methods directly as callbacks (tear-offs) may causing binding issues where this becomes undefined. Workaround: Wrap callbacks in a lambda to preserve context.

// ❌ Avoid (may fail based on transpiler version)
onPressed: _incrementCounter

// βœ… Recommended
onPressed: () => _incrementCounter()

Initialization

To set up the project for development (both Dart and JavaScript packages), run the following command from the root directory:

# 1. Get Dart dependencies
dart pub get

# 2. Initialize project (installs JS dependencies)
dart run tool/init.dart

Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.

# Clone the repo
git clone https://github.com/flutterjsdev/flutterjs.git

# Set up the project (Follow 'Initialization' steps above)
# 1. dart pub get
# 2. dart run tool/init.dart

License

BSD 3-Clause "New" or "Revised" License β€” see LICENSE for details.


Links


FlutterJS
Write Flutter. Ship the Web.

Releases

No releases published

Packages

 
 
 

Contributors

Languages