Getting Started

Get up and running with PersonQL in minutes.

Installation

PersonQL provides framework-specific SDKs. Choose the one that matches your stack:

React

npm install @personql/react
# or
yarn add @personql/react
# or
pnpm add @personql/react

Next.js

npm install @personql/nextjs

React Native

npm install @personql/react-native

Node.js (Server-side)

npm install @personql/node

Vanilla JavaScript

npm install @personql/vanilla

Quick Setup

1. Get Your API Key

Sign up at PersonQL Dashboard and create a new project to get your API key.

2. Configure Your Environment

Add your API key to your environment variables:

PERSONQL_API_KEY=your_api_key_here
PERSONQL_BASE_URL=https://api.personql.com

3. Initialize PersonQL

React Example

import { PersonQLProvider, useAuth } from '@personql/react';
 
// Wrap your app with the provider
function App() {
  return (
    <PersonQLProvider
      apiKey={process.env.PERSONQL_API_KEY}
      baseURL={process.env.PERSONQL_BASE_URL}
    >
      <YourApp />
    </PersonQLProvider>
  );
}
 
// Use authentication in your components
function YourApp() {
  const { user, signIn, signOut, isLoading } = useAuth();
 
  if (isLoading) {
    return <div>Loading...</div>;
  }
 
  return (
    <div>
      {user ? (
        <>
          <h1>Welcome, {user.email}!</h1>
          <button onClick={signOut}>Sign Out</button>
        </>
      ) : (
        <button onClick={() => signIn({ provider: 'google' })}>
          Sign In with Google
        </button>
      )}
    </div>
  );
}

Next.js Example

// app/layout.tsx
import { PersonQLProvider } from '@personql/nextjs';
 
export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en">
      <body>
        <PersonQLProvider>
          {children}
        </PersonQLProvider>
      </body>
    </html>
  );
}

Next Steps

Now that you have PersonQL installed and configured:

  1. Set up authentication - Configure OAuth providers and MFA
  2. Explore the SDKs - Learn framework-specific features
  3. Review API reference - Dive into the complete API

Common Use Cases

Social Authentication

// Google OAuth
signIn({ provider: 'google' });
 
// GitHub OAuth
signIn({ provider: 'github' });
 
// Microsoft OAuth
signIn({ provider: 'microsoft' });

Email/Password Authentication

// Sign up
signUp({ email: 'user@example.com', password: 'secure-password' });
 
// Sign in
signIn({ email: 'user@example.com', password: 'secure-password' });

Multi-Factor Authentication

// Enable MFA
enableMFA({ method: 'totp' });
 
// Verify MFA
verifyMFA({ code: '123456' });

Session Management

// Get current session
const session = useSession();
 
// Track custom event
session.track('button_clicked', { button: 'checkout' });

Need Help?