Stack Navigator- How to disable/reset back button?

My app starts from the home page and later progresses to further screens laid out sequentially one after another all of which are contained in one stack navigator. Now each page contains an ‘exit’ button that will exit the current screen and navigate directly to the home page. However, in this case, there remains an option on the top button to go back to the previously open page and swipe gestures also provide this functionality. This hampers the functionality of my app and I am looking for a way to restrict users from going back. How can I implement this in Thunkable X? Any help is appreciated! :slightly_smiling_face:

P.S. I have considered creating a splash screen outside the stack navigator which redirects to the home page when opened but that seems to damage the user experience.


Hi @Ritvik_Singh1, apologies for the delay getting back to you.

I’m just wondering if you need a stack navigator at all in your app? If want your user to progress in a linear fashion, perhaps you could just create your own navigation bar?

How many screens are in your app? what sort of app are you trying to build?

Here is an idea that I do not have the time to test, but that might work.

Each screen has a “When Screen opens” event and a “When Screen starts”, one of those ought to be triggered when someone goes back or swipes (remains to be tested on my side).
But if you started in screen1, then got to screen2 using a control button, then to screen3 using a button in screen2, you could set a variable to take a specific value each time you enter a new screen using a button (i.e. clicking the “go to page 3” on screen2 would set the variable to 3 before calling "navigate to screen3).
So you are in screen3 and the “when screen opens” or “when screen starts” could check the value of that variable. Screen3 sees the value is 3, and all is fine.
But then, the user swipes or click the back button. So now, screen2 opens. But the variable was NOT set to 2, since only clicking the button “go to screen 2” would have done so. So then your logic is “if the screen# does not match the one last requested by clicking buttons and saved in the variable, then navigate to screen1”