@gradio/lite) allows you to run Gradio applications entirely in the browser using WebAssembly and Pyodide. This means you can create interactive machine learning demos without any server infrastructure.
Overview
Gradio Lite runs Python code directly in the browser using Pyodide, a Python distribution compiled to WebAssembly. This enables:- Serverless demos: No backend infrastructure needed
- Static hosting: Deploy to GitHub Pages, Netlify, or any static host
- Privacy: All computation happens client-side
- Instant loading: No server cold starts
Gradio Lite is ideal for lightweight demos and educational content. For production apps with heavy computation or external dependencies, consider regular Gradio deployed to Hugging Face Spaces.
Quick start
Create an HTML file with your Gradio app embedded:Installation
Via CDN (recommended)
Include Gradio Lite from a CDN:Via npm
For bundled applications:Writing Gradio Lite apps
Basic structure
Write your Gradio Python code inside<gradio-lite> tags:
Multiple files
Organize code across multiple files using<gradio-file> tags:
Install dependencies
Specify Python packages to install:Only packages available in Pyodide can be installed. Check the Pyodide package list for available packages.
Examples
Image processing
Data visualization
Text processing
Deployment
Gradio Lite apps are just HTML files, so you can deploy them anywhere:GitHub Pages
- Create an
index.htmlfile with your Gradio Lite app - Push to a GitHub repository
- Enable GitHub Pages in repository settings
- Your app will be live at
https://username.github.io/repo-name
Netlify
- Create an
index.htmlfile - Drag and drop to Netlify Drop
- Get an instant deployment URL
Any static host
Deploy to:- Vercel
- Cloudflare Pages
- AWS S3 + CloudFront
- Google Cloud Storage
- Or any web server
Limitations
- Package availability: Only Pyodide-compatible packages work
- Performance: WebAssembly is slower than native Python for heavy computation
- File size: Large dependencies increase initial load time
- Browser compatibility: Requires modern browsers with WebAssembly support
- No server features: No server-side APIs, databases, or external services
Best practices
1
Keep dependencies minimal
Only include packages you actually need. Fewer dependencies = faster load times.
2
Optimize for client-side
Gradio Lite works best for lightweight processing. For heavy models, use regular Gradio.
3
Test in multiple browsers
Verify your app works in Chrome, Firefox, Safari, and Edge.
4
Add loading indicators
The initial load can take time. Consider adding a loading message.
When to use Gradio Lite
Good use cases ✅
- Educational demos and tutorials
- Simple data visualizations
- Text processing tools
- Mathematical calculators
- Image filters and transformations
- Static portfolio projects
Not recommended ❌
- Large ML models (use Hugging Face Spaces)
- Heavy computation (use server-side Gradio)
- Real-time data from APIs (needs backend)
- Production applications (needs reliability)
- Apps requiring authentication (needs server)
Next steps
Sharing apps
Learn about sharing regular Gradio apps
Hugging Face Spaces
Deploy full Gradio apps to Spaces