tezvyn:

Auth-protected routes via GoRouter redirect

Source: interviewintermediate

WHAT IT TESTS: guarding routes with redirect. OUTLINE: a top-level redirect reads auth state, sends unauthenticated users to login, sends logged-in users away from login, and uses refreshListenable to re-evaluate on auth change.

WHAT IT TESTS: whether you can centralize auth gating in the router rather than scattering checks. ANSWER OUTLINE: define a top-level redirect callback that reads the current auth status and the requested location; if unauthenticated and not heading to login, return the login path, and if authenticated but on login, return home; otherwise return null to allow navigation. Supply a refreshListenable so the router re-runs redirect when auth state changes.

Read the original → interview

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Auth-protected routes via GoRouter redirect · Tezvyn