I'm using react 18.2 on my FrontEnd and flask with flask-login on my Backend. It's a RestAPI setup and the authentication will be using sessions.
I implemented the login itself, React sends login requests Flask handles it and puts a session token in browser's cookies.
My question: When user connected I want to show him login_required components but I'm confused how can I check it with React. Also if user closes the browser and returns later.
I thought of a solution: Every time user makes something I will send a request to Flask and check if this user is authenticated and hence connected.
My solution (Not sure if it is the best practices): I have a login_required endpoint in flask. I just check on the FrontEnd if the response is OK.