Appsilon / shiny.router

A minimalistic router for your Shiny apps.
http://appsilon.github.io/shiny.router
Other
256 stars 31 forks source link

Feature request: support dynamic population of `make_router()` #79

Open uvedhe opened 3 years ago

uvedhe commented 3 years ago

I was very excited to discover shiny.router and incorporate it into my Shiny application. Managed to get it to work only to realise a caveat in my specific situation: I've built a Shiny app that uses a browser's cookie to determine the permissions a user has (allowing it to show certain tabs but not others). This functionality requires the tabs to be populated in server.R, since the cookie must be passed using Shiny's input$. However, make_router() must be ran in Global.R to be available to ui.R.

Initially I fixed this by only displaying the buttons/links for the tabs the user was allowed to see, but then noticed that the way router works is that it populates the entire ui, then toggles hide/show depending on the URL we're on (clever!). However, in my example this means the user can see tabs they shouldn't be able to see by simply going into their browser's console.

Another solution would be to dynamically populate make_router(), but that's not possible since the permissions aren't known yet to Global.R, since it's ran before server.R.

It'd be great if 'make_router()' could somehow support a dynamic inclusion/exclusion (ran from Server.R). Might be quite a stretch, but thought I'd highlight it just in case!

Thanks for all the great work