Initial page load remove the landing page and just load the login form
-
I need help, I am just trying to load the FusionAuth login screen without showing the landing page with the login button first. I am not sure how to automate the event that redirects and loads the FusionAuth login page in my react application.
-
To achieve this, you'll need to use a routing mechanism in your React application to handle the navigation flow. One popular library for managing routes in React is React Router. Here's a step-by-step guide on how you can automate the redirect to the FusionAuth login page:
Install React Router in your project by running the following command in your terminal:
Copy code
npm install react-router-dom
In your React application, create a new file (let's call it AppRouter.js) where you'll define your routes. Import the necessary components from React Router:
jsx
Copy code
import { BrowserRouter as Router, Route, Redirect } from 'react-router-dom';
import { FusionAuthLogin } from './FusionAuthLogin'; // Replace with the actual component for FusionAuth login
Set up your routes within the Router component. Define a route that matches the landing page and redirects to the FusionAuth login page:
jsx
Copy code
const AppRouter = () => {
return (
<Router>
<Route exact path="/">
<Redirect to="/login" />
</Route>
<Route path="/login" component={FusionAuthLogin} />
{/* Add more routes for other pages in your application */}
</Router>
);
};export default AppRouter;
-
Your approach is assuming I built my own login component. I want to use the login UI generated by FusionAuth, when the user clicks on the login button that is a component inside the fusionauth react-sdk. I want to completely remove this initial workflow, so when the user launches the application the root route with redirect the user to /oauth2/authorize endpoint.
-
@jacksontrevan - Let me start of by saying I am not very familiar with React applications. However, thinking about typical application flow, What would happen if the user was already logged in? Can't you get the login screen by just directing them to a secured page vs a "landing page"?