Can I block navigating to a view by url but still allow routing programmatically?

Viewed 137

To summarize I still want to allow a user to click a button and be taken to a view that is in our react router like how it works today. However, I never want the user to be allowed to navigate to this view by url in their web browser. Just want to permanently block that for that specific view. Is there any simple ideas for pulling this off without having to work with local storage?

I saw a similar question here but it is asking for the whole application when I just want it this way for one specific view. The answer also seems to involve authentication. React router:I don't want user to directly navigate to pages by typing urls but allow going to pages only using links inside the app.

Thanks!

1 Answers

You can add these special <Route/> when your app is fully loaded or with a specific action. If routes don't exist on first load or without a specific action, he can't reach these routes with the url.

Related