ๆƒฏๆ€ง่šๅˆ ้ซ˜ๆ•ˆ่ฟฝ่ธชๅ’Œ้˜…่ฏปไฝ ๆ„Ÿๅ…ด่ถฃ็š„ๅšๅฎขใ€ๆ–ฐ้—ปใ€็ง‘ๆŠ€่ต„่ฎฏ
้˜…่ฏปๅŽŸๆ–‡ ๅœจๆƒฏๆ€ง่šๅˆไธญๆ‰“ๅผ€

ๆŽจ่่ฎข้˜…ๆบ

ๅš
ๅšๅฎขๅ›ญ - Franky
ๅฅ‡ๅฎขSolidotโ€“ไผ ้€’ๆœ€ๆ–ฐ็ง‘ๆŠ€ๆƒ…ๆŠฅ
ๅฅ‡ๅฎขSolidotโ€“ไผ ้€’ๆœ€ๆ–ฐ็ง‘ๆŠ€ๆƒ…ๆŠฅ
ๆœ‰่ตžๆŠ€ๆœฏๅ›ข้˜Ÿ
ๆœ‰่ตžๆŠ€ๆœฏๅ›ข้˜Ÿ
aimingoo็š„ไธ“ๆ 
aimingoo็š„ไธ“ๆ 
WordPressๅคงๅญฆ
WordPressๅคงๅญฆ
ไบบไบบ้ƒฝๆ˜ฏไบงๅ“็ป็†
ไบบไบบ้ƒฝๆ˜ฏไบงๅ“็ป็†
้…ท ๅฃณ โ€“ CoolShell
้…ท ๅฃณ โ€“ CoolShell
L
LangChain Blog
Blog โ€” PlanetScale
Blog โ€” PlanetScale
้˜ฎไธ€ๅณฐ็š„็ฝ‘็ปœๆ—ฅๅฟ—
้˜ฎไธ€ๅณฐ็š„็ฝ‘็ปœๆ—ฅๅฟ—
Microsoft Azure Blog
Microsoft Azure Blog
ไบ‘้ฃŽ็š„ BLOG
ไบ‘้ฃŽ็š„ BLOG
Google DeepMind News
Google DeepMind News
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
Hugging Face - Blog
Hugging Face - Blog
Y
Y Combinator Blog
D
DataBreaches.Net
Engineering at Meta
Engineering at Meta
MyScale Blog
MyScale Blog
ๅคง็Œซ็š„ๆ— ้™ๆธธๆˆ
ๅคง็Œซ็š„ๆ— ้™ๆธธๆˆ
S
SegmentFault ๆœ€ๆ–ฐ็š„้—ฎ้ข˜
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Donโ€™t Fail โ€” They Drift Spilling beans for how i learn for exam๐Ÿ˜"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" โ€” What Actually Happened Comfy Cloudโ€™s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions โ€” here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components โ€” Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cรณmo construรญ un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 ๐Ÿš€ I Built an Ethical Hacking Scanner Tool โ€“ Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points โ€” Here's What I Found About How Markets Really Move EcoTrack AI โ€” Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I Served My React SPA from Android Assets Like a Professi...
Giovani Fouz ยท 2026-05-04 ยท via DEV Community

๐Ÿš€ I Served My React SPA from Android Assets Like a Professional Web Server โ€” Here's What Happened

First load: 77ms. Reload: 2ms. 38x faster with LRU cache. No server, no permissions, no dependencies.


๐Ÿค” The Problem Every React Dev Faces

You've got your SPA running perfectly on localhost:5173. React, TypeScript, TailwindCSS, React Router, lazy loading... everything works beautifully.

Now you need to take it to Android.

Your traditional options:

// Option 1: Capacitor โ€” 30MB runtime, complex config
// Option 2: Cordova โ€” 15MB, outdated plugins
// Option 3: file:// protocol โ€” broken CORS, SPA routes don't work
// Option 4: 50-line homemade script โ€” fragile, no cache, no security

Enter fullscreen mode Exit fullscreen mode

None of them feel right. You want something lightweight, fast, secure, and respectful of your architecture.


โœจ The Solution: WebVirt Engine

An Android library of ~600 lines that simulates a virtual web server inside the WebView. Your SPA thinks it's at https://app.local, but everything comes from assets/.

// 5 lines. That's it.
WebVirt.with(this)
    .host("app.local")
    .bind(webView);

webView.loadUrl("https://app.local/");

Enter fullscreen mode Exit fullscreen mode

That's all. Your React app running. SPA routes intact. No weird configuration.


๐Ÿ”ฌ But Don't Take My Word for It. Look at the Real Data.

To validate that WebVirt Engine was as fast as promised, I needed real metrics. Not synthetic benchmarks. Not "it feels fast." Cold, hard data.

The Secret Weapon: WebVirtMetrics

WebVirt Engine includes an optional metrics module that captures every asset load in real time:

// Enable only in debug. Zero overhead in production.
WebVirtMetrics.ENABLED = BuildConfig.DEBUG;
WebVirtMetrics.startSession();

// Every asset WebVirt loads gets recorded:
// - File path
// - Load time in milliseconds
// - Whether it came from cache or disk
// - Size in bytes
// - MIME type

Enter fullscreen mode Exit fullscreen mode

Metrics are automatically persisted using LoggingUtil, which writes a log file to the device storage without requiring any permissions.


๐Ÿ“Š The Results (Real Financial App)

Stack: React 18 + TypeScript + TailwindCSS + Vite + React Router
Assets: 1.4MB (3 main files + 13 lazy chunks)
Device: Physical Android, mid-range

First Load (Assets from Disk)

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘     WEBVIRT ENGINE - PERFORMANCE REPORT          โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ Session duration:         4214 ms              โ•‘
โ•‘ Total assets loaded:         3                  โ•‘
โ•‘ Total load time:            77 ms              โ•‘
โ•‘ Avg load time:              25 ms              โ•‘
โ•‘ Min load time:              10 ms              โ•‘
โ•‘ Max load time:              49 ms              โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ Cache hits:                  0                  โ•‘
โ•‘ Cache misses:                3                  โ•‘
โ•‘ Cache hit rate:           0.0%                 โ•‘
โ•‘ Bytes from cache:            0 bytes           โ•‘
โ•‘ Total bytes loaded:    1426251 bytes           โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ HTTP errors:                 0                  โ•‘
โ•‘ SPA fallbacks:               1                  โ•‘
โ•‘ Range requests:              0                  โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ BY MIME TYPE:                                    โ•‘
โ•‘   HTML                 x1    avg   10ms           โ•‘
โ•‘   CSS                  x1    avg   18ms           โ•‘
โ•‘   JavaScript           x1    avg   49ms           โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ RECENT LOADS (last 5):                           โ•‘
โ•‘   ๐Ÿ“„ /index.html                      10msโ•‘
โ•‘   ๐Ÿ“„ /assets/index-DGe01YXs.css       18msโ•‘
โ•‘   ๐Ÿ“„ /assets/index-B3g6t1vt.js        49msโ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Enter fullscreen mode Exit fullscreen mode

3 assets. 77ms total. Zero errors.

The 4214ms "session" includes: app startup, welcome animation, and the user tapping the "Start" button. WebVirt only took 77ms.


Second Load (LRU Cache in RAM)

By long-pressing the WebView (a hidden debug gesture), I forced a reload to measure cache performance:

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘     WEBVIRT ENGINE - PERFORMANCE REPORT          โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ Session duration:          513 ms              โ•‘
โ•‘ Total assets loaded:         3                  โ•‘
โ•‘ Total load time:             2 ms              โ•‘
โ•‘ Avg load time:               0 ms              โ•‘
โ•‘ Min load time:               0 ms              โ•‘
โ•‘ Max load time:               1 ms              โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ Cache hits:                  3                  โ•‘
โ•‘ Cache misses:                0                  โ•‘
โ•‘ Cache hit rate:         100.0%                 โ•‘
โ•‘ Bytes from cache:      1426251 bytes           โ•‘
โ•‘ Total bytes loaded:    1426251 bytes           โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ RECENT LOADS (last 5):                           โ•‘
โ•‘   ๐Ÿ’พ /index.html                      1msโ•‘
โ•‘   ๐Ÿ’พ /assets/index-B3g6t1vt.js        0msโ•‘
โ•‘   ๐Ÿ’พ /assets/index-DGe01YXs.css       1msโ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Enter fullscreen mode Exit fullscreen mode

3 assets. 2ms total. 100% cache hit rate.

Notice the emoji: ๐Ÿ’พ = served from cache. The JS bundle took 0ms (less than 1ms, rounded down). HTML took 1ms. CSS took 1ms.


๐Ÿ“ˆ The Side-by-Side Comparison

Metric First Load Reload (Cache) Improvement
Total load time 77ms 2ms 38.5x faster
Average time 25ms 0ms Instant
Slowest asset 49ms (JS) 1ms (CSS) 49x faster
Cache hit rate 0% 100% Perfect
Bytes transferred 1.4MB 0 All from RAM
HTTP errors 0 0 Perfect


๐Ÿง  Why Is It So Fast?

WebVirt Engine uses an in-memory LRU cache with SHA-1 ETags:

First load:
  assets/index-B3g6t1vt.js โ†’ read from APK โ†’ cached in RAM โ†’ ETag generated

Second load:
  assets/index-B3g6t1vt.js โ†’ ETag match? โ†’ Yes โ†’ 304 Not Modified โ†’ 0ms

Enter fullscreen mode Exit fullscreen mode

ยท No asset decoding (Android stores them compressed in the APK)
ยท No disk I/O on reloads (everything in RAM)
ยท No real HTTP header parsing (everything is local)
ยท LruCache with memory awareness that cleans up on onTrimMemory()


๐Ÿ”’ Security That Doesn't Sacrifice Speed

Every response includes automatic security headers:

Content-Security-Policy: default-src 'self'; script-src 'self'...
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Access-Control-Allow-Origin: *

Enter fullscreen mode Exit fullscreen mode

And CSP is fully configurable:

WebVirt.with(this)
    .host("app.local")
    .cspPolicy("default-src 'self'; script-src 'self' https://api.external.com")
    .bind(webView);

Enter fullscreen mode Exit fullscreen mode


๐Ÿค Plays Beautifully with Nexus

Need native APIs? Nexus is a JavaScript โ†” Android bridge that doesn't interfere with WebVirt:

// WebVirt: serves the SPA
WebVirt.with(this).host("app.local").bind(webView);

// Nexus: export, import, PDF, camera, whatever you need
Nexus.installOn(webView)
    .registerHandler("export", new ExportAdapter())
    .registerHandler("import", new ImportAdapter())
    .registerHandler("pdf", new PdfAdapter())
    .initialize()
    .withFilePicker(this);

nexus.attachToWebViewLifecycle(); // Doesn't break WebVirt

webView.loadUrl("https://app.local/");

Enter fullscreen mode Exit fullscreen mode

WebVirt doesn't know Nexus exists. Nexus doesn't know WebVirt exists. They collaborate without coupling. This is real architecture.


๐Ÿ—๏ธ The Architecture That Makes This Possible

WebView
  โ”œโ”€โ”€ WebViewClient โ†’ WebVirt (owner)
  โ”‚     โ””โ”€โ”€ shouldInterceptRequest() โ†’ assets/
  โ”‚
  โ”œโ”€โ”€ WebViewLifecycleObserver โ†’ Nexus (decorator)
  โ”‚     โ””โ”€โ”€ Wraps WebVirt's client without breaking it
  โ”‚
  โ””โ”€โ”€ JavascriptInterface โ†’ Nexus (parallel channel)
        โ””โ”€โ”€ window.__nexus.call("export", data)

Enter fullscreen mode Exit fullscreen mode

Three layers that don't compete. Decorator Pattern for lifecycle. Builder Pattern for fluent configuration. Strategy Pattern for PathHandlers.


๐Ÿ“ฆ Production Proven

This isn't a "hello world" library. It's running in production in a real financial app with:

ยท โš›๏ธ React 18 + TypeScript + TailwindCSS
ยท ๐Ÿ“ฆ 5MB of assets (1.4MB main bundle)
ยท ๐Ÿ”€ React Router with lazy loading
ยท ๐Ÿ“ค Native JSON export
ยท ๐Ÿ“ฅ Native JSON import with FilePicker (no permissions required)
ยท ๐Ÿ“„ Native PDF export
ยท ๐Ÿ”’ Restrictive CSP
ยท โšก 77ms first load, 2ms reloads


๐Ÿš€ Coming Soon to GitHub & JitPack

WebVirt Engine v3.1.1

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.fouzstack:webvirt-engine:3.1.1'
}

Enter fullscreen mode Exit fullscreen mode

Nexus v2.0.0

implementation 'com.github.fouzstack:nexus:2.0.0'

Enter fullscreen mode Exit fullscreen mode


๐ŸŽฏ Is This for You?

โœ… Use WebVirt Engine if you:

ยท Have an SPA in React/Vue/Svelte
ยท Want full control without heavy dependencies
ยท Need maximum offline performance
ยท Value clean architecture and real decoupling

โŒ Not for you if you:

ยท Need hot reload during development (for now)
ยท Your company is already committed to Capacitor/Cordova
ยท Your app is purely native with no web content


๐Ÿ™ Acknowledgments

To Fouzstack for creating and maintaining both WebVirt and Nexus.
To the GoF design patterns that still hold up 30 years later.
To WebVirtMetrics and LoggingUtil for making it possible to collect this data without extra permissions.
And to you, for reading this far.


Questions? Ideas? Want to contribute? The repos will be open for issues and PRs as soon as they go live.

Drop a comment: Which metric surprised you most? The 77ms first load or the 2ms cached reload?