Hacker News new | ask | show | jobs
by madeofpalk 2241 days ago
There's not really much of a delimma. This is a problem that was solved in "single page apps" 10 years ago.

    - links are for navigation
    - buttons are for action
Styling and appearance are not a factor - you can make buttons look like links, links look like buttons.

Simple rule is "should this view have a url". Should the user be able to navigate directly to this page? Should it exist in the history? Should the user be able to share a URL to that page to someone else? Most times the answer to all of these is.

In your javascript application, it is trivial to do single page app view navigations (without triggering a full browser request) by listening to link clicks and acting on it just as you would if it were a button click. All frameworks and routing libraries will handle this for you out of the box. If you roll your own, its not that difficult to add this functionality.

2 comments

You're just making blanket assumptions about pretty hard UX problems.

Are tabs a view? Should they be buttons or links? What if the tabs are in the sidebar in some widget?

What about collapsible items? HN uses JavaScript to store your collapsible preferences to your account. Not shareable but consistent on page refresh. Is that good? I don't know.

The fact is, in PWA world, what's a links and what's a button is blurred, and there's nothing wrong with admitting it.

Should "book now" be a button or a link?

It is an action, but it navigates you to the booking page. That page should have a url and should be able to be shared. But wanting to "book now" is an action and most sites have them as a button.

I will reword GP: if your <button> onClick navigates to another URL, your button is not a button but a link.