Publishing Your Shiny App: A Comprehensive Guide to shinyapps.io
Written on
Introduction to Publishing Shiny Apps
The surge of interactive applications and dashboards during the COVID-19 pandemic has inspired many creators. Recently, a reader inquired about the process of publishing her newly developed Shiny app. Drawing from a previous article that detailed how to upload R code to GitHub, I decided it would be beneficial to share the steps I follow to publish my Shiny apps.
Before diving into the deployment process, you can preview my Shiny apps here.
Note: The screenshots provided in this guide were captured on MacOS. If you are using Windows, please share your experience in the comments.
Note: While there are various methods for publishing apps (such as using Docker), the approach outlined here is straightforward and effective.
Prerequisites for Deployment
To follow this guide, you will need to create an account on the shinyapps.io platform, which I personally utilize for deploying my Shiny applications. They offer a free tier that supports up to five active applications with a limit of 25 active hours per month. If you anticipate a wider audience for your app, be prepared to exceed this monthly cap quickly. To accommodate more than five apps or to increase the active hours, you will need to opt for a paid plan.
Step-by-Step Publishing Process
Here are the steps to publish your Shiny app, illustrated with images.
Step 1: Launch RStudio and initiate a new Shiny app:
Step 2: Assign a name (without spaces), select a save location, and click the Create button:
Step 3: Similar to creating a new R Markdown document, a basic Shiny app code will be generated. Click the Run App button to see it in action:
Step 4: Once the basic app is open, it’s time to publish:
Step 5: If this is your first app, the "Publish From Account" section will be empty. Click "Add New Account" to connect your shinyapps.io account:
Step 6: Select the first option (ShinyApps.io):
Step 7: Click on the link to access your ShinyApps account:
Step 8: Click the Dashboard button to log into your account:
Step 9: Click on your name, then on Tokens:
Step 10: If you haven't created any tokens yet, click on "Add Token." Then press the Show button:
Step 11: Click the Show Secret button:
Step 12: The code will now be fully visible. Click the Copy to clipboard button:
Step 13: Paste the code into the console in RStudio and execute it:
Your system is now authorized to deploy apps to your shinyapps.io account.
Step 14: Return to the publishing window, assign a title (without spaces), and click the Publish button:
Step 15: After a few moments (depending on your app's size), your Shiny app should open in your web browser:
Step 16: You can now edit your app or replace its entire code. To illustrate this, I added a link for more information in the side panel:
Step 17: Verify that your changes are reflected (the link should appear in the side panel) and republish the app:
Step 18: Click the Publish button again:
Step 19: Congratulations! Your app is now live, and you can share the link with others:
Additional Notes on App Settings
To modify your Shiny app settings, navigate to your shinyapps.io dashboard and select the app you just published:
Explore the various settings available in the tabs at the top of the window, and find the link to your app next to the URL field:
Publishing Your Dataset
If your Shiny app relies on a dataset not loaded by default in R (for instance, one saved locally), you will need to publish that data alongside your app (ensure to check the box for your dataset):
Alternatively, for greater flexibility, you can host your dataset online. If you own a website, you can publish it there. If not, consider using GitHub to host your dataset (if you don't have an account, now is a great time to create one!). Finally, import the data into your app using the new URL.
Thank you for reading this guide. I hope it assists you in publishing your first Shiny app. As always, feel free to leave any questions or suggestions in the comments to benefit other readers.
Video Resources
To enhance your understanding of deploying Shiny apps, check out these video tutorials:
How to Deploy R Shiny App for Free on Shinyapps.io
This video provides a comprehensive walkthrough on deploying your Shiny app for free using shinyapps.io.
Publishing apps to shinyapps.io
This tutorial explains the steps necessary to publish your applications effectively on shinyapps.io.