---
title: 3. Adding auth APIs
description: Add authentication APIs to your backend using SuperTokens for sign in and sign up functionality.
sidebar:
  order: 4
---

We will add all the backend APIs for auth on `/api/auth`. This can be changed by setting the `apiBasePath` property in the `appInfo` object in the `appInfo.ts` file. For the rest of this page, we will assume you are using `/api/auth`.

## 1. Create the `app/api/auth/[[...path]]/route.ts` route
- Be sure to create the `auth/[[...path]]` folder in the `app/api/` folder.
- `route.ts` uses the `getAppDirRequestHandler` helper from `supertokens-node` to handle authentication APIs such as sign-up and sign-in. The full folder path should be `/app/api/auth/[[...path]]/route.ts`.
- An example of this can be found [here](https://github.com/supertokens/next.js/blob/canary/examples/with-supertokens/app/api/auth/%5B...path%5D/route.ts).

## 2. Expose the SuperTokens APIs


```tsx title="app/api/auth/[[...path]]/route.ts" check=false reason="Requires surrounding framework application context"
import { getAppDirRequestHandler } from "supertokens-node/nextjs";
import type { NextRequest } from "next/server";
import { ensureSuperTokensInit } from "../../../config/backend";

ensureSuperTokensInit();

const handleCall = getAppDirRequestHandler();

export async function GET(request: NextRequest) {
  return handleCall(request);
}

export async function POST(request: NextRequest) {
  return handleCall(request);
}

export async function DELETE(request: NextRequest) {
  return handleCall(request);
}

export async function PUT(request: NextRequest) {
  return handleCall(request);
}

export async function PATCH(request: NextRequest) {
  return handleCall(request);
}

export async function HEAD(request: NextRequest) {
  return handleCall(request);
}
```

## 3. Use the login widget
If you are now able to sign in or sign up, this means the backend setup is done correctly! If not, please feel free to ask questions on [Discord](https://supertokens.com/discord)
