Stack Auth
GuidesSDKComponentsAPI Reference
Back to home
Platform
OverviewFAQ
Getting Started
SetupComponentsUsersProduction
Concepts
API KeysBackend IntegrationCustom User DataEmailsJWT TokensOAuth
OAuth Providers
Orgs and TeamsPermissionsStack AppTeam SelectionUser OnboardingWebhooks
Customization
Custom PagesCustom StylesDark ModeInternationalization
Page Examples
Other
Self-hostMCP SetupConvex
Stack Auth Docs

Setup

Welcome to the React SDK setup guide! If you're looking for guides for other frameworks, check out the Next.js SDK Setup, or the JavaScript SDK Setup.

Before getting started, make sure you have a React project setup. We show an example here of a Vite React project.

We recommend using our setup wizard for a seamless installation experience. The wizard automatically detects your project structure and walks you through the setup process. If you encounter any issues with the wizard, you can follow our manual installation steps instead.

Run installation wizard

Run Stack's installation wizard with the following command:

Terminal
npx @stackframe/init-stack@latest

Update API keys

Then, create an account on the Stack Auth dashboard, create a new project with an API key, and copy its values into the stack/client.ts file created by the wizard.

Wrap your app

This example uses react-router, but all React apps should wrap the app with StackProvider and StackTheme.

App.tsx
import { StackHandler, StackProvider, StackTheme } from "@stackframe/react";
import { Suspense } from "react";
import { BrowserRouter, Route, Routes, useLocation } from "react-router-dom";
import { stackClientApp } from "./stack/client";

function HandlerRoutes() {
  const location = useLocation();
  return (
    <StackHandler app={stackClientApp} location={location.pathname} fullPage />
  );
}

export default function App() {
  return (
    <Suspense fallback={null}>
      <BrowserRouter>
        <StackProvider app={stackClientApp}>
          <StackTheme>
            <Routes>
              <Route path="/handler/*" element={<HandlerRoutes />} />
              <Route path="/" element={<div>hello world</div>} />
            </Routes>
          </StackTheme>
        </StackProvider>
      </BrowserRouter>
    </Suspense>
  );
}

Done!

That's it! Stack is now configured in your React project. If you start your app and navigate to http://localhost:5173/handler/sign-up, you will see the sign-up page.

SignIn

After signing up/in, you will be redirected back to the home page. You can also check out the http://localhost:5173/handler/account-settings page.

Previous PageFAQ
Next PageComponents

Table of Contents

Navigate this page

On this page

Run installation wizardUpdate API keysWrap your appDone!Install npm packageCreate API keysCreate stack/client.ts fileUpdate App.tsxDone!

Stack Auth AI

Documentation assistant

Experimental: AI responses may not always be accurate—please verify important details.

For the most accurate information, please join our Discord or email us.

How can I help?

Ask me about Stack Auth while you browse the docs.