Hacker News new | ask | show | jobs
by wyqydsyq 2252 days ago
Yeah it's a trade-off and button links what this person would be experiencing.

General best practice IMO is any navigation link/button that is just some permalink like a profile page should be an a tag to support natural browser interactions like open in new tab or bookmark link, it also helps crawlers index your app if the interface in question is some sort of public directory you'd like indexed and has SSR. Only navigation based on ephemeral state (submitting forms etc) to things nobody would typically share a link to (logout URL, submit button going to a thankyou page) should be buttons.

1 comments

Yeah, another way of putting it is a link is great for GET requests while a button is better for POST requests (form submissions, AJAX, etc.) If you use a link for these, you have to think about what the href points to, you can’t just use JavaScript alone when it’s a link. If it’s a button, JS is more acceptable due to the inability to open new tabs, etc.