question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow href in Links to be a string

See original GitHub issue

Since Next allows href to be a string in Links, 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:closed
  • Created a year ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
tatethurstoncommented, Oct 23, 2022

Yes continuing with the implementation sounds great, thanks

1reaction
tatethurstoncommented, Oct 22, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found