User authentication in R Shiny – sneak peek of shiny.users and shiny.admin packages

[This article was first published on Appsilon Data Science Blog, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

At Appsilon we frequently build advanced R/Shiny dashboards that need user authentication. I would like to share with you how we implement user management – user accounts, the authorization process and gather usage statistics to have a better understanding of how the app is used.

For user authentication, we created the shiny.users package. For user administration and usage statistics, we created the shiny.admin package. We will show you a sneak peek of how these packages work. They are not released yet – but we opened an Early Adopter Waitlist – sign up and we will contact you as soon as these packages will be ready for production testing!

Shiny.users – convenient authentication on the application level

Here is an example of how shiny.users works when you add it to your shiny application:

Below you can view the code of this example:


demo_users <- list(
    username = "demo-appsilon", 
    password = "QZt85C46Ab", 
    roles = list("basic", "admin")
    username = "john", 
    password = "C4SRx3xJcy", 
    roles = list("basic")

ui <- shinyUI(fluidPage(
  div(class = "container", style = "padding: 4em",

server <- shinyServer(function(input, output) {
  users <- initialize_users(demo_users)
  callModule(login_screen, 'login_screen', users)

  output$authorized_content <- renderUI({
    if (!is.null(users$user()) {
      ... # application content

shinyApp(ui, server)

This is a simple demo with users defined in a list. In a real-world scenario, you would store user credentials in a database or authenticate users with an external API. This is also covered in shiny.users.

In bigger apps with more users, you will also need user management, authorization management (different roles e.g. admin, writer, reader, etc) and usage statistics. For such advanced use cases, we created shiny.admin package.

Shiny.admin - user management and usage statistics

This package is an extension to the shiny.users package. When you add it to your Shiny app, you instantly get admin panel under the url http://application-url/#!/admin. This panel is only accessible by the users with “admin” role.

Features of shiny.admin:

  • Adding and removing users
  • Managing existing users - their passwords, roles and metadata
  • Statistics - counting unique users and sessions (similar to Google Analytics)
  • Session recording - recording defined actions e.g. provided input values and clicked elements. You can view all sessions details (similar to Hotjar)

We observed huge gains from above features. We exactly understood how our apps were used by our users. Here are some screenshots from shiny.admin:

I hope you like the idea of shiny.users and shiny.admin packages. Let us know what would you expect from user accounts and admin panel features. Do you think there is a need for developing such packages? Tell us about your use cases and needs in the comments or contact us at [email protected]

Also, don’t forget to sign up to shiny.users and shiny.admin waitlist!

Read the original post at Appsilon Data Science Blog.

Follow Appsilon Data Science

To leave a comment for the author, please follow the link and comment on their blog: Appsilon Data Science Blog. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)