SolidJSS
SolidJSโ€ข2y agoโ€ข
2 replies
Deimos

Problem importing useSession from vinxi/http

I'm currently working on SolidStart with Firebase auth. The problem is whenever I try to use useSession() it raises an error saying

Error: Module "node:async_hooks" has been externalized for browser compatibility. Cannot access "node:async_hooks.AsyncLocalStorage" in client code. See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.

import {
  GoogleAuthProvider,
  signInAnonymously,
  signInWithPopup,
} from "firebase/auth";
import { auth } from "./client-firebase";
import { useSession } from "vinxi/http";

const googleProvider = new GoogleAuthProvider();

export const signInWithGoogle = async () => {
  try {
    const userCredential = await signInWithPopup(auth, googleProvider);
    console.log("Signed in with Google:", userCredential.user);

    // Create user session and store session data
    const token = userCredential.user.getIdToken();
  } catch (error) {
    console.error("Error signing in with Google:", error);
    throw error;
  }
};

export const signInAsAGuest = async () => {
  try {
    const userCredential = await signInAnonymously(auth);
    console.log("Signed in as guest:", userCredential.user);

    // Create user session and store session data
    const token = userCredential.user.getIdToken();
    const session = await useSession({
      password: import.meta.env.SESSION_SECRET,
    })

  } catch (error) {
    console.error("Error signing in as guest:", error);
    throw error;
  }
};
Next Generation Frontend Tooling
Vite
Was this page helpful?