Temporary share links
Gradio demos can be easily shared publicly by settingshare=True in the launch() method:
A share link usually looks something like this: https://07ff8706ab.gradio.live. The link is served through Gradio Share Servers, which are only a proxy for your local server and do not store any data sent through your app.
Share link limitations
- Share links expire after 72 hours
- Share links are publicly accessible, meaning anyone can use your model for prediction
- By default,
share=False(except in Google Colab notebooks, where share links are automatically created)
Permanent hosting on Hugging Face Spaces
If you’d like to have a permanent link to your Gradio demo on the internet, use Hugging Face Spaces. Hugging Face Spaces provides the infrastructure to permanently host your machine learning model for free! After you have created a free Hugging Face account, you have two methods to deploy your Gradio app:Method 1: Deploy from terminal
Rungradio deploy in your app directory. The CLI will:
- Gather basic metadata about your app
- Upload all files in the current directory (respecting
.gitignore) - Launch your app on Spaces
- Re-run the
gradio deploycommand, or - Enable GitHub Actions in the CLI to automatically update the Space on
git push
Method 2: Deploy from browser
Drag and drop a folder containing your Gradio model and all related files to Hugging Face Spaces.SSH port forwarding alternative
As an alternative to using share links, you can use SSH port-forwarding to share your local server with specific users. This approach:- Doesn’t expose your app publicly
- Gives you control over who can access your app
- Doesn’t have time limitations
- Requires users to have SSH access to your machine
Deep links for sharing app state
You can add a button to your Gradio app that creates a unique URL you can use to share your app and all components as they currently are with others. This is useful for sharing unique and interesting generations from your application, or for saving a snapshot of your app at a particular point in time. To add a deep link button to your app, place thegr.DeepLinkButton component anywhere in your app:
For the deep link URL to be accessible to others, your app must be available at a public URL. Be sure to host your app on Hugging Face Spaces or use the
share=True parameter when launching your app.Embedding your Gradio app
Once you have hosted your app on Hugging Face Spaces (or on your own server), you may want to embed the demo on a different website, such as your blog or portfolio. You can embed interactive demos even in static websites, such as GitHub pages. There are two ways to embed your Gradio demos, with quick links available in the “Embed this Space” dropdown on your Space page.Web components (recommended)
Web components typically offer a better experience than iframes:- Load lazily (won’t slow down your website)
- Automatically adjust height based on content
- More customizable
- Import the Gradio JS library (replace
{GRADIO_VERSION}with your version):
- Add the
<gradio-app>element where you want the app:
Web component attributes
You can customize the appearance and behavior with these attributes:src: The URL of the hosted Gradio demospace: Shorthand for Hugging Face Spaces (e.g.,"gradio/Echocardiogram-Segmentation")control_page_title: Whether to set the HTML title to the app title (default:"false")initial_height: Initial height while loading (default:"300px")container: Whether to show the border frame and hosting info (default:"true")info: Whether to show hosting info below the app (default:"true")autoscroll: Whether to scroll to output after prediction (default:"false")eager: Whether to load immediately on page load (default:"false")theme_mode: Use"dark","light", or"system"theme (default:"system")