Streamlit has revolutionized how data scientists and developers create interactive web applications. As your app gains traction, you might want to move beyond the default subdomain provided by Streamlit.io. This guide will walk you through deploying your Streamlit app with a custom domain, enhancing its professional appearance and brand identity.
We’ll explore the deployment process on Streamlit.io, discuss its limitations, and then show you how to use Ploomber.io to deploy your app with a custom domain. By the end of this post, you’ll have a clear understanding of how to take your Streamlit app to the next level with a personalized URL.
Understanding Domains
As we prepare to elevate your Streamlit app with a custom domain, it’s crucial to understand what domains and custom domains actually are. A domain, or domain name, is the web address users type into their browser to access a specific site. It’s structured hierarchically, typically consisting of:
- Top-level domain (TLD): The rightmost part, like
.com
or.org
- Second-level domain: The unique name you choose
- Subdomain: An optional prefix, such as
www
For example, in www.example.com
, com
is the TLD, example
is the second-level domain, and www
is the subdomain.
A custom domain is one you personally choose and register, rather than using a default domain provided by a hosting service. Instead of yourapplication.streamlit.app
, you might use yourapplication.com
. This gives you full control over your app’s web address, enhancing your brand identity.
You can purchase custom domains from various domain registrars such as GoDaddy and Namecheap. These services typically charge an annual fee for domain registration and management.
Now that we understand the basics of custom domains, let’s explore how to implement one for your Streamlit application.
The Streamlit.io Approach
Let’s start by examining the deployment process on Streamlit’s native platform:
Setting Up Your App on Streamlit.io
- Create an account on Streamlit.io
- Connect your GitHub repository
- Select the repository containing your Streamlit app or choose one of the demo applications
- Configure your app settings
- You can choose a custom subdomain at this step.
Changing Your Subdomain
- Go to your app’s settings
- Navigate to the
General
section - Enter your desired subdomain (e.g., my-super-demo.streamlit.app)
The Limitation: Subdomain Constraints
While Streamlit.io offers a straightforward deployment process, it’s important to note that it only supports subdomains. This means your app URL will typically follow the format yourapplication.streamlit.app
. For many users, especially those building professional or commercial applications, this limitation can impact their branding strategy.
Leveraging Ploomber.io for Custom Domain
For those seeking complete control over their domain, Ploomber.io offers a solution. Here’s how you can use the platform to deploy your Streamlit application with a custom domain:
Getting Started with Ploomber.io
- Sign up for a Ploomber.io account
- Click on
New
to deploy a new application
Deploying Your Streamlit Application
- Prepare your Streamlit app for deployment
- Create a zip containing your application
- Upload the zip when creating a new project
You can also use the cli if you prefer!
pip install ploomber-cloud
ploomber-cloud init
ploomber-cloud deploy
Custom Domain Configuration
- Go to your dashboard
- Select the
•••
of your application - Click on
Settings
- Navigate to the
Custom Domains
section - Add your custom domain (e.g., myapp.com)
- Update your DNS records as instructed
Understanding DNS and Registrars
Before updating your DNS settings, let’s clarify what DNS and registrars are:
- DNS (Domain Name System): Think of DNS as the internet’s phone book. It translates human-readable domain names (like myapp.com) into IP addresses that computers use to identify each other on the network. When you type a domain name into your browser, DNS is what directs you to the correct server.
- Domain Registrar: This is the company where you purchased your domain name. Popular registrars include GoDaddy and Namecheap. They manage the reservation of domain names and assign IP addresses to those domain names.
Updating Your DNS Settings
To point your custom domain to your Ploomber-hosted Streamlit app, you’ll need to update your DNS records. Here’s how:
- Log in to your domain registrar’s website.
- Find the DNS management section (often called
DNS Settings
orName Server Management
). - You’ll need to to copy the record displayed to your DNS:
- The A record: This points your domain to Ploomber’s IP address.
- A CNAME record: This creates an alias for your domain.
- Add the records as specified. It will look like this:
- A ALIAS record: @ as host, and yourapp.ploomberapp.io as value
- A CNAME record: www as host, and yourapp.ploomberapp.io as value
- A CNAME record: with the shown CNAME name and CNAME value (as displayed in the SSL certification status section)
⚠️ Some DNS providers don’t support ALIAS records. If that’s your case, you might try adding a CNAME record.
For me on Namecheap, it looks like the following:
- For more info: Documentation on the subject.
- Don’t hesitate to contact us if you need help!
Remember to save your changes and be patient - DNS propagation can take up to 48 hours, but it’s often much quicker.
Launching Your Application
- Once DNS propagation is complete, your app will be accessible via your custom domain
- Verify the deployment by visiting your new custom URL or by looking at the available domains for your app in the dashboard
Conclusion
By following this guide, you’ve learned how to deploy your Streamlit application using two different methods. While Streamlit.io offers a quick deployment option with subdomain limitations, Ploomber.io provides the flexibility of custom domain integration, allowing for a more personalized and professional web presence.
Choose the method that best aligns with your project requirements and branding strategy. With your Streamlit app now accessible via a custom domain, you’re well-positioned to showcase your work professionally and build your online presence effectively.
If you need further help deploying a Streamlit application with a custom domain, don’t hesitate to reach out to us!