@mateothegreat/svelte5-router - 2.15.3
    Preparing search index...

    Class RouteResult

    A route result that includes the evaluation results of the route.

    This type is necessary for the internal workings of the router to ensure that the evaluation results are included in the route result and to avoid requiring it to be merged in the original route instance.

    2.0.0

    const routeResult = new RouteResult({
    router: myRouter,
    route: myRoute,
    result: {
    path: {
    condition: "exact-match",
    original: "/users/123",
    params: { id: "123" }
    },
    querystring: {
    condition: "exact-match",
    original: { filter: "active" },
    params: { filter: "active" }
    },
    component: UserComponent,
    status: 200
    }
    });
    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    result: {
        component?: any;
        path: { condition: Condition; original: string; params?: ReturnParam };
        querystring: {
            condition: Condition;
            original: ReturnParam;
            params?: ReturnParam;
        };
        status: number;
    }

    The comprehensive result of routing evaluation that rendered this route.

    This object contains all the information gathered during the route matching process, including path evaluation, querystring parsing, component resolution, and status determination.

    Type declaration

    • Optionalcomponent?: any

      The component that was resolved and rendered when the route became active.

      This represents the actual component instance, snippet, or component factory that was determined during the routing process. It can be a direct component reference, a lazy-loaded component function, or a Svelte snippet.

      2.0.0

      undefined
      
      • Component Svelte component type
      • Snippet Svelte snippet type
      // Direct component reference
      component: UserProfile

      // Lazy-loaded component
      component: () => import('./UserProfile.svelte')

      // Svelte snippet
      component: mySnippet

      This is undefined when the route doesn't render a component directly, such as when using hooks for custom rendering logic

    • path: { condition: Condition; original: string; params?: ReturnParam }

      The path evaluation results containing the matched path information.

      This object provides detailed information about how the current URL path was matched against the route's path pattern, including any extracted parameters.

      2.0.0

      // For a route with path "/users/:id" and URL "/users/123"
      const pathResult = {
      condition: "exact-match",
      original: "/users/123",
      params: { id: "123" }
      };
      • condition: Condition

        The evaluation condition indicating how the path was matched.

        2.0.0

        Condition For available condition types

        "exact-match" | "base-match" | "no-match"
        
      • original: string

        The original path string that was evaluated during routing.

        This represents the actual path portion of the URL that was processed, without query parameters or hash fragments.

        2.0.0

        "/users/123/profile"
        

        This path is normalized and may differ from the raw URL path

      • Optionalparams?: ReturnParam

        The parameters extracted from the path during evaluation.

        Contains named parameters extracted from the path pattern matching, such as route parameters defined with :paramName syntax or regex groups.

        2.0.0

        undefined
        
        // For route "/users/:id" matching "/users/123"
        params: { id: "123" }

        // For regex route "^/posts/(?<slug>.+)$" matching "/posts/my-article"
        params: { slug: "my-article" }

        ReturnParam For parameter value types

        This is undefined when no parameters are extracted from the path

    • querystring: { condition: Condition; original: ReturnParam; params?: ReturnParam }

      The querystring evaluation results containing parsed query parameters.

      This object provides information about how the URL's query string was processed and any parameters that were extracted or matched.

      2.0.0

      // For URL "?filter=active&page=2"
      const querystringResult = {
      condition: "exact-match",
      original: { filter: "active", page: "2" },
      params: { filter: "active", page: "2" }
      };
      • condition: Condition

        The evaluation condition indicating how the querystring was matched.

        2.0.0

        Condition For available condition types

        "exact-match" | "partial-match" | "no-match"
        
      • original: ReturnParam

        The original querystring data that was evaluated during routing.

        This can be either a parsed object representation of query parameters or the raw querystring, depending on how the route was configured.

        2.0.0

        ReturnParam For supported parameter types

        // Parsed object format
        original: { filter: "active", sort: "name" }

        // Raw string format
        original: "filter=active&sort=name"
      • Optionalparams?: ReturnParam

        The parameters extracted from the querystring during evaluation.

        Contains the processed query parameters after applying any route-specific querystring matching rules and transformations.

        2.0.0

        undefined
        

        ReturnParam For parameter value types

        // Standard query parameters
        params: { search: "term", page: "1" }

        // With type conversion
        params: { page: 1, active: true }

        This may be undefined if no querystring processing was required

    • status: number

      The HTTP-style status code representing the result of the routing operation.

      This numeric code indicates the outcome of the route evaluation process, following HTTP status code conventions for consistency and familiarity. The status helps determine how the route result should be handled by status handlers and middleware.

      2.0.0

      status: 200  // Successful route match
      status: 404 // Route not found
      status: 401 // Unauthorized access
      status: 500 // Internal routing error

      Common values include 200 (OK), 404 (Not Found), 401 (Unauthorized), 403 (Forbidden), and 500 (Internal Server Error)

    2.0.0

    The result object is immutable once created and represents a snapshot of the routing state.

    // Accessing route evaluation results
    console.log(routeResult.result.path.original); // "/users/123"
    console.log(routeResult.result.path.params?.id); // "123"
    console.log(routeResult.result.status); // 200
    route?: Route

    The route that was evaluated to render this result.

    2.0.0

    This may be undefined if the route result was created without an associated route.

    Route

    Methods

    • The string representation of the route including the querystring.

      Returns string