T
TanStack2d ago
gradual-turquoise

Notify users frontend version changed

Hello, I want to notify my users with a toast, that the current version of the web app is outdated and they need to reload their page. Anyone suggestions how to archive that?Thank you!
1 Reply
other-emerald
other-emerald2d ago
I've done a very basic implementation for this. This is how it works: - create a env var for the app version, eg. VITE_APP_VERSION that you set to the git hash (I use Github actions, so can just use ${{ github.sha }}. It is important that it is prepended with VITE_ so that it is available client and server-side - create a server handler endpoint. eg. /version that just returns the env var - use tanstack query to make a request to this /version endpoint using a refetchInterval of 5 minutes or whatever time works for you - on the client compare the server response to the VITE_APP_VERSION the client has. If it differs, there is a new version. - show a pop-up to inform the user to refresh

Did you find this page helpful?