Loading video...
Video Failed to Load
Statically typed links are coming to Next.js: ◆ Autocompletion ◆ Error on invalid routes ◆ Prevents 404 links during build ◆ Dynamic, catch-all, and optional catch-all routes ◆ Works with both `pages` and `app` ◆ No extra configuration needed!
278,585 views • 3 years ago •via X (Twitter)
11 Comments

TypeScript error with hints if you made a typo:

Autocompletion for static links when editing:

Dynamic routes with parameters:

Catch-all and optional catch-all routes are supported too:

@nextjs Nice!

@nextjs can this work with custom link components too, or only those imported from next/link?

@nextjs (Deleted my previous reply as I got it wrong) For custom components you will have to type it with a `Route` type, imported from Next.js, instead of using `string`. And then it will just work!

@nextjs Very niceeee!!!

@nextjs This is a gamechanger 🤯

@nextjs Interesting — how will this work? How would Typescript know about file system? Is the dev server compiling types while using fs?

@nextjs Yes, type declarations will be generated by the dev server
