If you want to reload the page after the session is expired, you could use meta refresh and set the time to the session expiry duration.
There’s also this gem that you can use to have more control over the timeout behavior.
An alternative would be to implement the timeout actions you need on client side, using vanilla js or stimulus.
I would prefer following this client path than using server side logic, but it’s just my opinion.