Does Supabase provide an Auth React+TypeScript example?

Hello, I followed https://supabase.com/docs/guides/auth/quickstarts/react but I'm struggling because the example doesn't pass eslint type checking. What's the recommended way to use supabase auth with react and typescript? The team I'm on is starting this project with strict type checking from the start.

We don't have anything complicated, just a blank project created with:

npm create vite@latest my-app -- --template react-ts


Here are the eslint errors we ran into:

# eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0
  37:5   error  Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator  @typescript-eslint/no-floating-promises
  48:18  error  Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function                                                  @typescript-eslint/no-confusing-void-expression


Line 37 is line 13 in the example, the useEffect call body:

supabase.auth.getSession().then(({ data: { session } }) => {
  setSession(session)
})


Line 48 is line 23 in the example, the call to:

return () => subscription.unsubscribe()
Was this page helpful?