Allow href in Links to be a string
See original GitHub issueSince Next allows href
to be a string in Link
s, it would be nice to also offer this more compact syntax (e.g.: Allow users to write href="/"
instead of href={{ pathname: '/' }}
). We can still make this typed so that only the corresponding string literals are allowed.
If this sounds like a good idea, I can create the PR with the implementation 😃
Issue Analytics
- State:
- Created a year ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
JavaScript: String link() method - TechOnTheNet
The link() method returns a string containing an <a> element. The value of string is enclosed in <a> and </a> tags as the...
Read more >JavaScript String link() Method - W3Schools
String link() is deprecated in JavaScript. Avoid using it. ... The link() method returns a string embedded in an <a> tag: <a href="url">string</a> ......
Read more >how render string to html link - Stack Overflow
Try this string link = String.Format("<a href=\"http://localhost:1900/ResetPassword/?username={0}&reset={1}\">Click here</a>", user.
Read more >HTML Link – How to Insert a Link to a Website with HREF Code
The href is an attribute used to reference another document. You can find it on link tags and anchor tags. The href attribute...
Read more >Links in HTML documents - W3C
This attribute describes the relationship from the current document to the anchor specified by the href attribute. The value of this attribute is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes continuing with the implementation sounds great, thanks
Hey @MariaSolOs I had this in an early version of nextjs-routes but the TypeScript error messages had poorer DX. Any typos in routes would present an error message using the first member of the routes union rather than the most similar member. This was several months ago so if the TS inference has improved in more recent versions or if you can find a way to express the type differently that helps TS yield a better error message (maybe a conditional type with the string and object variants instead of a single union?) I’m open to it. Also happy to support this via a config option if we can’t overcome the error messaging DX.