Usage

Type values passed between routes.

tsx
// Type values passed between routes.
import type { ParamValue, RouteParams } from 'kuito';

// Builds the query part of a share link from a route's params.
function query(params: RouteParams): string {
  const pairs = Object.entries(params).map(
    ([name, value]: [string, ParamValue]) =>
      `${encodeURIComponent(name)}=${encodeURIComponent(String(value))}`,
  );

  return pairs.length ? `?${pairs.join('&')}` : '';
}

query({ id: 42, autoplay: true }); // '?id=42&autoplay=true'

Type declaration

ts
export type ParamValue = string | number | boolean;

Type

ts
string | number | boolean
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.