Auth Provider setup

Hi! I am currently setting up my auth provider and have two question: 1) For some reason, checkAuth is getting called 3 times every time I reload a page. What could be causing this? 2) I'd like to automatically trigger a login via redirect without the user having to click a button that triggers the login(). Is there a good way to do this?
4 Replies
foreign-sapphire
foreign-sapphire2y ago
Hi @misstsuliu , there may be several reasons why the checkAuth function may run more than once. - One of them is React Strick Mode. - Rendering the page with React Router - useAuthenticated or <Authenticated> component may be working in your project. What is your concern about this? We will look into this situation. The easiest way would be to create a custom page and use the useLogin hook there. Another option would be to make a method like in the supabase example project (https://github.com/refinedev/refine/blob/next/examples/dataProvider/supabase/src/App.tsx#L94)
metropolitan-bronze
metropolitan-bronze2y ago
Thanks for your response! The main concern is just a general one, around performance/call redundance.
foreign-sapphire
foreign-sapphire2y ago
We did not receive any performance issues with this. This is because of the reasons we have explained.
Omer
Omer2y ago
If your checkAuth method contains a costly operation then something is probably wrong for example: it should not contain requests with long response times