I have a question similar to the one posted here.
I'm building a React application which has very strict SEO requirements, so I'm wondering if the following approach is an issue:
For all of our navigation/routing, we're using onClick handlers that push the user to the new location within the app. The way I've built the components means that the generated HTML does not have anchor tags, and thus there are no links/hrefs anywhere in the application.
Can googlebot handle this? Even if it can, I have a feeling it may adversely affect crawlers' ability to properly index the linking structure within the app.
If this is an issue, I will need to add links to everything, and simply prevent the default behavior before triggering the route. This way the crawler would at least be able to see links with href attributes in the HTML that point to the proper URLs.
Unfortunately, since this is a new application, it's not publicly available yet for me to test using the Fetch as Google tool.
See here for an explanation to a similar question.
Googlebot should be able to handle onclick links. You can test it by seeing the crawl frequency of Googlebot in search console and seeing if it crawls the onclicks.
Google could probably handle onclick links but you should make a test before your app is finished. Nonetheless, I prefer the old fashion way to link in order to make easier the searchers job and avoid problems.
Have in mind that the Google's ajax crawling method was deprecated a few years ago and that could be because they are able to read the DOM, not just the source code (question 37).
As I said, I would use normal links but if you have to keep the onclick property, you should use: