Setup

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

Before getting started, make sure you have a JavaScript project set up (such as Node.js, Vite, or any other JavaScript framework).

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 Stack's installation wizard with the following command:

Terminal
npx @stackframe/init-stack@latest

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

stack/server.ts
import { StackServerApp } from "@stackframe/js";

export const stackServerApp = new StackServerApp({
  // You should store these in environment variables based on your project setup
  projectId: "your-project-id",
  publishableClientKey: "your-publishable-client-key",
  secretServerKey: "your-secret-server-key",
  tokenStore: "memory",
});

Example usage

import { stackServerApp } from "@/stack/server";

const user = await stackServerApp.getUser("user_id");

await user.update({
  displayName: "New Display Name",
});

const team = await stackServerApp.createTeam({
  name: "New Team",
});

await team.addUser(user.id);

Next steps

Check out the Users to learn how to retrieve and update user information, or Example pages to see how to build your sign-in/up pages.

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.