1

Toying around with Supabase to switch from firebase for a hobby project. Using facebook as auth provider, and it works fine. But when logging in the callback leaves a # in the URL. How do I get rid of it?

import { useState, useEffect } from "react";
import { createClient, Session } from "@supabase/supabase-js";

const supabase = createClient(process.env.dbUrl, process.env.dbKey);

cost App = () => {
  const [currentSession, setCurrentSession] = useState<Session | null>(null);

  const signIn = async () => await supabase.auth.signIn({
    provider: "facebook",
  });

  const signOut = async () => await supabase.auth.signOut();

  useEffect(() => {
    const session = supabase.auth.session();
    setCurrentSession(session);

    const { data: authListener } = supabase.auth.onAuthStateChange(
      (event, session) => setCurrentSession(session)
    );

    return () => {
      authListener?.unsubscribe();
    };
  }, []);

  return (
    <div className="App">
      <button onClick={signIn}>Sign In</button>
      <button onClick={signOut}>Sign Out</button>
      <pre>{JSON.stringify(currentSession, null, 2)}</pre>      
    </div>
  );
}

export default App;
  • I think this is already answered on Stack Overflow https://stackoverflow.com/questions/1397329/how-to-remove-the-hash-from-window-location-url-with-javascript-without-page-r/5298684#5298684, but also if the hash isn't causing any issues there is no need for removing it. – Andrew Smith Oct 09 '22 at 14:39

0 Answers0