4.0.1 • Published 8 months ago

@plusnew/router v4.0.1

Weekly downloads
56
License
-
Repository
-
Last release
8 months ago

plusnew-router Build Status Coverage Status

This router makes complete typesafety possible. At compile and runtime the typesafety is guaranteed, for the Route-Components and also the Links.

import { createRootRoute, schema } from "@plusnew/router";

const rootRoute = createRootRoute(
  // Defines what parameter the route can have
  {
    size: schema.number({ default: 20 }), // This parameter is optional and has a default of 20
    sortOrder: schema.string({
      default: "desc",
      validate: (value) => value === "asc" || value === "desc", // Creates typesafety of only allowing the literals "asc" and "desc"
    }),
  },
);

const childRoute = rootRoute.createChildRoute("childRouteName", {
  nestedParameter: schema.object({
    id: schema.number(),
  }),
});

const url = childRoute.createPath({
  "/": {
    size: 20,
    sortOrder: null, // "asc" | "desc" | null
  },
  childRouteName: { nestedParameter: { id: 5 } },
});

document.body.innerHTML =
  rootRoute.map(url, ({ hasChildRouteActive, parameter }) =>
    hasChildRouteActive
      ? childRoute.map(url, ({ hasChildRouteActive, parameter }) =>
          hasChildRouteActive
            ? null
            : `${parameter["/"].size} + ${parameter.childRouteName.nestedParameter.id}`,
        )
      : `Welcome ${parameter["/"].size}`,
  ) ?? "not found";
4.0.1

8 months ago

4.0.0

8 months ago

3.0.0

3 years ago

2.2.0

3 years ago

2.4.1

3 years ago

2.4.0

3 years ago

2.4.2

3 years ago

2.0.0

3 years ago

1.7.0

3 years ago

2.3.0

3 years ago

2.1.0

3 years ago

1.6.1

4 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.3

4 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.3.2

5 years ago

1.4.0

5 years ago

1.3.1

5 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

1.0.0-beta.4

6 years ago

1.0.0-beta.5

6 years ago

1.0.0-beta.6

6 years ago

1.0.0-beta.3

6 years ago

1.0.0-beta.2

6 years ago

1.0.0-beta.1

6 years ago

0.7.3

6 years ago

0.7.2

6 years ago

1.0.0-alpha.2

6 years ago

0.7.1

6 years ago

1.0.0-alpha.1

6 years ago

0.6.70

6 years ago

0.7.0

6 years ago

0.6.63

6 years ago

0.6.62

6 years ago

0.6.61

6 years ago

1.0.0-alpha.0

6 years ago

0.6.60

6 years ago

0.6.59

6 years ago

0.6.58

6 years ago

0.6.53

6 years ago

0.6.43

7 years ago

0.6.42

7 years ago

0.6.32

7 years ago

0.6.31

7 years ago

0.6.30

7 years ago

0.6.29

7 years ago

0.6.28

7 years ago

0.6.23

7 years ago

0.6.22

7 years ago

0.6.19

7 years ago

0.6.18

7 years ago

0.6.17

7 years ago

0.6.16

7 years ago

0.6.15

7 years ago

0.6.14

7 years ago