Utils

Scaffold Utils Just call me, i know a guy

  1. isValidEmail
  2. A utility function for validating email addresses.

    svelte
    Loading...
  3. isValidUrl
  4. A utility function for validating URLs.

    svelte
    Loading...
  5. handleRedirect
  6. 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

Last Updated: -


Previous

Next

© 2026 @sierra-95/svelte-scaffold. All rights reserved.