The issue you're experiencing with the UI not updating immediately after login is likely due to how Next.js handles client-side navigation and state updates. When you use redirect in a server action, it performs a full page reload, which can cause the UI to appear "stuck" or unstyled until the page refreshes. To fix this, you need to ensure that the client-side state updates properly after a successful login without requiring a full page reload.
Use useRouter for Client-Side Navigation
Instead of using redirect in the server action, use Next.js's useRouter hook to handle navigation on the client side. This ensures a smoother transition and avoids the full page reload.