Cookie Consent by Free Privacy Policy Generator Aktuallisiere deine Cookie Einstellungen ๐Ÿ“Œ Introducing a new router for Vue


๐Ÿ“š Introducing a new router for Vue


๐Ÿ’ก Newskategorie: Programmierung
๐Ÿ”— Quelle: dev.to

Brief history of my journey with vue-router

Virtually every developer using Vue.js is currently using or has only ever used vue-router. Many of those developers, myself included, are mostly happy with it. The biggest complaint I hear is the lack of strongly typed routes, which is usually solved with a bit of Typescript wrapping your routes.

// router/routes.ts
import { RouteLocationRaw, RouteRecordRaw } from 'vue-router'

type RouteFunction = (...args: any[]) => RouteLocationRaw

export const routes = {
  home: () => ({ name: 'home' }) as const,
  club: (clubId: string) => ({ name: 'clubs.view', params: { clubId } }) as const,
  profile: (userId?: string) => ({ name: 'profile.view', query: { userId } }) as const,
} satisfies Record<string, RouteFunction>

Then routes becomes your source of truth, so navigation should always use a route from routes to send proper names to vue-router.

<router-link :to="routes.club('club-123')">go to club</router-link>

The syntax of defining routes is a bit cumbersome but honestly works fairly well. However, because Iโ€™m a serial starter-of-new-projects and love a challenge, I teamed up with Pleek91 to see if we could build our own.

Introducing Kitbag Router

https://router.kitbag.dev

Itโ€™s intentionally different

We made the decision to start the project from scratch; solving problems from first principles rather than taking the path of so many others and try to build on top of the relatively old vue-router project. This means Kitbag Router is NOT a drop in replacement for projects using vue-router. Therefore, this freedom also means we can have a relentless pursuit of the best possible developer experience possible, not weighed down by having to have feature parity with vue-router.

First and foremost, itโ€™s type safe!

Kitbag Router uses a createRoutes utility that returns routes with the name, path, query, all preserved in the Route type. This means the routes you provide to createRouter will maintain type safety when accessing the current route or performing navigation.

Image description

Type safety in routing means auto complete when assigning to on <router-link>, easy discovery of available routes when defining a beforeRouteEnter hook, and ensuring that Typescript will error if the expected params for a route change without updating the router.push() call.

Params are way more powerful

Not only does Kitbag Router know what params are expected for a given route, it can also support param types beyond String.

Kitbag Router ships with built in support for params of typeString, Number, Boolean, Date, RegExp, JSON, as well as any custom param type you define. Not only is this type useful when navigating, but it also means a route that expects a number for an โ€œidโ€ param wonโ€™t be considered a match if the value provided in the URL doesnโ€™t satisfy the number constraint. Furthermore, your Vue component that gets rendered for the route doesnโ€™t have to worry about whether the param will be present or not or having to convert it from string to the type we know itโ€™s supposed to be.

Support for the query

Params arenโ€™t relegated to only the path. Kitbag Router allows you to configure your expected params in the query the same way youโ€™re used to defining params in other parts of the URL.

Handling rejections

Inevitably when defining your routes, youโ€™ll want to add a โ€œcatch allโ€ or โ€œnot foundโ€ route. While Kitbag Router fully supports defining plain olโ€™ Regex in your path/query, it also ships with even better support for handling NotFound. We call this a โ€œrejectionโ€, which is customizable and can be extended to any custom rejection you need, like perhaps NotAuthorized. When a rejection is triggered, usually from within one of your hooks, Kitbag Router will automatically render the rejection component you assigned for the given rejection type.

And moreโ€ฆ

These are the key features we think really make Kitbag Router compelling but there is so much more. Kitbag router is built for Vue3 and support async components, route hooks, editable params from useRoute, components for RouterLink and RouterView, and more.

Is it ready?

Kitbag Router is still super green and currently maintained by a team of 2. It has not yet had a stable release (on 0.2.0 as of the time Iโ€™m writing this), so things are still likely to change. That being said, I hope youโ€™ll give it a try, maybe give it a star. Weโ€™re excited to hear from the community on what features we should focus on next.

Happy engineering!

...



๐Ÿ“Œ Moving From Vue 1 To Vue 2 To Vue 3: A Case Study Of Migrating A Headless CMS System


๐Ÿ“ˆ 39.84 Punkte

๐Ÿ“Œ Introducing a new router for Vue


๐Ÿ“ˆ 32.17 Punkte

๐Ÿ“Œ NativeScript-Vue 2.0 erschienen: Native Mobile-Apps mit Vue


๐Ÿ“ˆ 26.56 Punkte

๐Ÿ“Œ Vue i18n โ€“ So erstellst Du mehrsprachige Vue.js Anwendungen!


๐Ÿ“ˆ 26.56 Punkte

๐Ÿ“Œ Easy Vue internationalization - guide to the Vue I18n plugin


๐Ÿ“ˆ 26.56 Punkte

๐Ÿ“Œ 500+ Vue.js Tailwind CSS UI Components - TailGrids Vue


๐Ÿ“ˆ 26.56 Punkte

๐Ÿ“Œ Efficiently Managing Remote Data in Vue with Vue Query


๐Ÿ“ˆ 26.56 Punkte

๐Ÿ“Œ Vue Designer 1.4 - Desktop editor to visually design Vue applications.


๐Ÿ“ˆ 26.56 Punkte

๐Ÿ“Œ HTML & Vue.js, a secrete you may not know about Vue


๐Ÿ“ˆ 26.56 Punkte

๐Ÿ“Œ Enhance the drag and drop of your Vue 3 application with Vue Fluid DnD


๐Ÿ“ˆ 26.56 Punkte

๐Ÿ“Œ Dynamic page title and description with Vue Router


๐Ÿ“ˆ 20.09 Punkte

๐Ÿ“Œ Navigating Success: Setting up Vue Router in yourย Project.


๐Ÿ“ˆ 20.09 Punkte

๐Ÿ“Œ Vue Modal Router


๐Ÿ“ˆ 20.09 Punkte

๐Ÿ“Œ Out-of-the-Box Router Tips: Top 4 Changes to Make on Your New Router


๐Ÿ“ˆ 16.24 Punkte

๐Ÿ“Œ New state management library for Vue 3


๐Ÿ“ˆ 15.9 Punkte

๐Ÿ“Œ # A new look at modals in vue 3


๐Ÿ“ˆ 15.9 Punkte

๐Ÿ“Œ New way of work with V-Model in Vue.js 3!


๐Ÿ“ˆ 15.9 Punkte

๐Ÿ“Œ New Developments: Retiring CTP and Introducing New Courses


๐Ÿ“ˆ 14.7 Punkte

๐Ÿ“Œ Juniper M-Series Router, MX-Series Router: Eine Schwachstelle ermรถglicht einen Denial-of-Service-Angriff


๐Ÿ“ˆ 13.62 Punkte

๐Ÿ“Œ Router-Vorschau: Fritzbox 6890 LTE wird kein Hybrid-Router


๐Ÿ“ˆ 13.62 Punkte

๐Ÿ“Œ Befรผrchteter Router-Lockdown: TP-Link-Router weiterhin fรผr Freifunk nutzbar


๐Ÿ“ˆ 13.62 Punkte

๐Ÿ“Œ BHU's 'Tiger Will Power' Wi-Fi Router May Be The Most Insecure Router Ever Made


๐Ÿ“ˆ 13.62 Punkte

๐Ÿ“Œ Asus ROG GT-AX11000: Gaming-Router soll "erster 10-GBit/s-WLAN-Router" sein


๐Ÿ“ˆ 13.62 Punkte

๐Ÿ“Œ Befรผrchteter Router-Lockdown: TP-Link-Router weiterhin fรผr Freifunk nutzbar


๐Ÿ“ˆ 13.62 Punkte

๐Ÿ“Œ [webapps] Tenda Wireless N150 Router 5.07.50 - Cross-Site Request Forgery (Reboot Router)


๐Ÿ“ˆ 13.62 Punkte

๐Ÿ“Œ #0daytoday #Tenda #Wireless N150 Router 5.07.50 - Cross-Site Request Forgery (Reboot Router) Exploi [#0day #Exploit]


๐Ÿ“ˆ 13.62 Punkte

๐Ÿ“Œ RouterSploit - Find Router Exploitation on Kali Linux 2018.2 (Router Exploitation Framework)


๐Ÿ“ˆ 13.62 Punkte

๐Ÿ“Œ Asus Router AsusWRT-Merlin router/httpd/web.c ej_update_variables action_script memory corruption


๐Ÿ“ˆ 13.62 Punkte

๐Ÿ“Œ Wlan-Router im Test : Router als Multitalente im Heimnetz


๐Ÿ“ˆ 13.62 Punkte

๐Ÿ“Œ TP-LINK Wireless Router Archer Router up to 1.0.0 Device Debug Protocol Stack-based memory corruption


๐Ÿ“ˆ 13.62 Punkte

๐Ÿ“Œ Router Konfiguration: Wie kann man den Router konfigurieren?


๐Ÿ“ˆ 13.62 Punkte

๐Ÿ“Œ GL.iNet Beryl travel router review: Pocket-sized secure router with VPN and Tor


๐Ÿ“ˆ 13.62 Punkte

๐Ÿ“Œ [webapps] ExpressVPN VPN Router 1.0 - Router Login Panel's Integer Overflow


๐Ÿ“ˆ 13.62 Punkte

๐Ÿ“Œ #0daytoday #ExpressVPN VPN Router 1.0 - Router Login Panels Integer Overflow Vulnerability [#0day #Exploit]


๐Ÿ“ˆ 13.62 Punkte











matomo