Scaffold Utils Just call me, i know a guy
- isValidEmail
- isValidUrl
- handleRedirect
A utility function for validating email addresses.
svelte
Loading...A utility function for validating URLs.
svelte
Loading...The most practical way to understand this is through a Sign In / Sign Up flow. Imagine a user is on page X and tries to access page Y, but page Y requires authentication. In that case, the user is redirected to a login page, and after successful authentication, sent back to their original destination.
handleRedirect builds this flow by taking a base route (e.g. the login page), an optional redirect target, and structured parameters for both. It then constructs the final URL and handles the navigation.
Keep in mind that your login page must read and handle the redirectTo parameter to complete the flow. Below are examples showing how to use handleRedirect in different scenarios.
svelte
Loading...Here is the type definition:
typescript
Loading...Simple navigation with params
http://localhost:5173/login?reason=session_expired&retry=true
typescript
Loading...Basic redirect
http://localhost:5173/login?redirectTo=%2Fdashboard
typescript
Loading...Redirect with params
http://localhost:5173/utils?source=admin_panel&redirectTo=%2Fmanage%2Fuser%3Fstatus%3Dpending%26filter%3Demail_verified
typescript
Loading...Replace state
typescript
Loading...Hard redirect
By default, handleRedirect uses goto. If softRedirect is set to false, it will use window.location for a hard redirect.
typescript
Loading...Edit Page