rahul2001
rahul2001

Reputation: 1657

How do you do web routes in React and React Router?

I have all my /api routes that require auth going through node but I want to also expose and have web routes that I can do in react and decouple from the server.

Is there a way to have react (or react router) handle web routes?

Upvotes: 0

Views: 135

Answers (1)

Colin Ramsay
Colin Ramsay

Reputation: 16466

Well, that's basically what React Router is for. It'll act upon changes to the URL and instantiate the component that you specify in your routes.

Without React Router, just treat it in the same way as you would any JavaScript project: listen for history changes or hash changes and re-render accordingly. But with React Router you have a solution that integrates with React and provides utility functions and hooks to make life easier.

Upvotes: 2

Related Questions