@futureverse/next-auth
Auth.js (Next-Auth) provider for FuturePass — pure server-side OAuth handler.
Futureverse winddown
Futureverse (the publisher of @futureverse/*) is in winddown. The hosted services this package talked to (auth.futureverse.app, pass-api.futureverse.app, signer.futureverse.app) have been re-hosted by gen3labs at futurepass.gen3labs.tech (issuer) and fpsigner.gen3labs.tech (signer). For new projects, switch to the matching @gen3labs/* package — drop-in surface, default URLs already point at the gen3labs infra. The Asset Register API has no community replacement yet; see the Migration playbook for the per-package map.
- Version
1.0.6- Published
- 2025-09-16
- License
- n/a
- Status
fv-winddown- npm
- https://www.npmjs.com/package/@futureverse/next-auth
- Types
./index.d.ts- Maintainers
- admin-futureverse, garethdainesnpm, jcsanpedro
- Depends on
@futureverse/auth-core- Peer deps
next-auth- Recent versions
1.0.0·1.0.1·1.0.2·1.0.3·1.0.4-beta.0·1.0.4·1.0.5·1.0.6
Why use it
You use Next.js with Auth.js and want FuturePass as a sign-in provider alongside Google/Apple.
When to skip it
Client-side-only React app — use @futureverse/auth-react instead.
Pairs with
next-auth— host framework
Example
import FuturePass from '@futureverse/next-auth/providers/futurepass';
export const authConfig = {
providers: [FuturePass({ clientId: process.env.FP_CLIENT_ID })],
};Upstream README
Futureverse Next Auth
Provides an OAuth authentication provider for FuturePass with Next-Auth (Auth.js). This package enables server-side authentication in Next.js applications.
Installation
npm:
npm install @futureverse/next-auth next-auth@beta --savenpm install wagmi viem @tanstack/react-queryyarn:
yarn add @futureverse/next-auth next-auth@beta
yarn add wagmi viem @tanstack/react-queryUsage
1. Configure Next-Auth
auth.ts
import NextAuth from 'next-auth';
import Futureverse from '@futureverse/next-auth/provider';
import { createNextAuthClient } from '@futureverse/next-auth';
import { QueryClient } from '@tanstack/react-query';
const clientId = '<your-futureverse-client-id>';
// Optional configuration
const authorizationUrl = 'https://login.passonline.cloud'; // Optional - defaults to production
const signerURL = 'https://signer.passonline.cloud'; // Optional - defaults to production
const issuer = 'https://login.futureverse.cloud'; // Optional - defaults to production
export const { auth, handlers, signIn, signOut } = NextAuth({
providers: [
Futureverse({
clientId,
authority: authorizationUrl, // Optional
issuer, // Optional
}),
],
session: {
strategy: 'jwt',
},
secret: process.env.AUTH_SECRET, // Required - add to your .env file
callbacks: {
async jwt({ token, profile }) {
// On first sign in, profile exists
if (profile) {
token.eoa = profile.eoa;
token.custodian = profile.custodian;
token.chainId = profile.chainId;
token.futurepass = profile.futurepass;
token.sub = profile.sub ?? undefined;
token.profile = profile.profile;
}
return token;
},
async session({ session, token }) {
session.user.eoa = token.eoa;
session.user.custodian = token.custodian;
session.user.chainId = token.chainId;
session.user.futurepass = token.futurepass;
session.user.sub = token.sub;
session.user.profile = token.profile;
return session;
},
},
});
// Create the Futureverse Next Auth client for client-side operations
export const authClient = createNextAuthClient({
clientId,
authorizationURL: authorizationUrl, // Optional
signerURL, // Optional
issuer, // Optional
chainId: 7672, // Optional - defaults to TRN Mainnet
hostWeb3SigningDomain: 'localhost:3000',
});
// Create query client
export const queryClient = new QueryClient();2. Setup API Route
app/api/auth/[...nextauth]/route.ts
import { handlers } from '@/auth';
export const { GET, POST } = handlers;3. Using Authentication
Server Components
import { auth } from '@/auth';
export default async function Page() {
const session = await auth();
if (!session) {
return <div>Not authenticated</div>;
}
return (
<div>
<p>Welcome {session.user.futurepass}</p>
<p>EOA: {session.user.eoa}</p>
</div>
);
}Client Components
'use client';
import { useSession } from 'next-auth/react';
import { signIn, signOut } from 'next-auth/react';
export default function AuthButton() {
const { data: session } = useSession();
if (session) {
return (
<button onClick={() => signOut()}>
Sign out
</button>
);
}
return (
<button onClick={() => signIn('futureverse')}>
Sign in with FuturePass
</button>
);
}Session Types
The session object includes FuturePass-specific fields:
interface Session {
user: {
email?: string | null;
name?: string | null;
image?: string | null;
eoa?: string;
custodian?: string;
chainId?: number;
futurepass?: string;
sub?: string;
profile?: any;
};
}Environment Variables
Add to your .env.local:
AUTH_SECRET=your-auth-secret-hereGenerate a secret using:
openssl rand -base64 32Integration with Auth UI
For a complete authentication UI experience, use @futureverse/auth-ui which provides pre-built authentication components and flows for both Web3 wallets and FuturePass custodial authentication.