Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Guest Users

Guest accounts allow users to immediately start using your application without going through a full registration process. This feature is particularly useful for applications where you want to reduce friction in the user onboarding process.

Key features

  • Locally persisted, so guest users can leave and return to the same account on the same device
  • Fully functional embedded wallets
  • Upgradeable to full accounts with email, social login, or phone
  • Can be logged out and deleted as needed

Create a guest account

Use the signUpGuest method to create a guest account. This returns an AuthResponse with isAnonymous: true in the user object:

auth.tsx
import openfort from "./openfortConfig";
 
async function handleGuest() {
  const result = await openfort.auth.signUpGuest();
 
  console.log('Guest user created:', result.user.id);
  console.log('Is anonymous:', result.user.isAnonymous);
}

Upgrade a guest account

Convert a guest user to a full account by adding an email address. Use addEmail to send a verification email:

auth.tsx
import openfort from "./openfortConfig";
 
async function upgradeGuestWithEmail(email: string) {
  const result = await openfort.auth.addEmail({
    email: email,
    callbackURL: 'https://your-app.com/verify-email',
  });
 
  console.log('Verification email sent');
}

After the user verifies their email, they can log in with email and password. The guest account is upgraded to a full account.

You can also upgrade guest accounts using:

Example implementation

Here's a complete example of a guest authentication flow:

GuestAuth.jsx
import openfort from "./openfortConfig";
import { useState } from "react";
import { useRouter } from "next/navigation";
 
function GuestAuth() {
  const router = useRouter();
  const [status, setStatus] = useState(null);
 
  const handleGuest = async () => {
    setStatus({ type: "loading", title: "Creating guest account..." });
 
    try {
      const result = await openfort.auth.signUpGuest();
 
      setStatus({ type: "success", title: "Guest account created" });
      console.log('Guest user ID:', result.user.id);
 
      router.push("/");
    } catch (error) {
      setStatus({ type: "error", title: "Error creating guest account" });
    }
  };
 
  return (
    <div>
      <button onClick={handleGuest} disabled={status?.type === "loading"}>
        {status?.type === "loading" ? "Creating..." : "Continue as Guest"}
      </button>
    </div>
  );
}
Copyright © 2023-present Alamas Labs, Inc