Currently, I am in the process of creating a Vue game that consists of two main views: a 'setup' view and a 'play' view. The values that are configured in the setup view are then passed as props to the play view, initiating the game with those specific parameters.
However, there is a potential issue where users can directly access the .../#/play
route without going through the setup process to set the required props. To address this, I have implemented default values as a temporary solution...
props: {
prop: { default: 'default value' },
// ...
},
...yet, I am contemplating on how to completely restrict access to the play view if a user did not navigate from the setup view .../#/setup
. While I am familiar with using required: true
and navigation guards, I am uncertain about the best approach to apply them in this scenario or if they are the most effective solutions available.
Is there a simple method to automatically redirect users when directly accessing the .../#/play
route?