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

  1. Create an account on Streamlit.io
  2. Connect your GitHub repository
  3. Select the repository containing your Streamlit app or choose one of the demo applications
  4. Configure your app settings
  • You can choose a custom subdomain at this step.

Streamlit.io deployment interface

Changing Your Subdomain

  1. Go to your app’s settings
  2. Navigate to the General section
  3. Enter your desired subdomain (e.g., my-super-demo.streamlit.app)

subdomain configuration

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

  1. Sign up for a Ploomber.io account
  2. Click on New to deploy a new application

Deploying Your Streamlit Application

  • Prepare your Streamlit app for deployment
    1. Create a zip containing your application
    2. Upload the zip when creating a new project

ploomber.io deployment interface

You can also use the cli if you prefer!

pip install ploomber-cloud

ploomber-cloud init
ploomber-cloud deploy

Custom Domain Configuration

  1. Go to your dashboard
  2. Select the ••• of your application
  3. Click on Settings
  4. Navigate to the Custom Domains section
  5. Add your custom domain (e.g., myapp.com)

Ploomber.io custom domain configuration

  1. 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:

  1. Log in to your domain registrar’s website.
  2. Find the DNS management section (often called DNS Settings or Name Server Management).
  3. 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.
  4. 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: namecheap dns

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

  1. Once DNS propagation is complete, your app will be accessible via your custom domain
  2. Verify the deployment by visiting your new custom URL or by looking at the available domains for your app in the dashboard

Demo

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!