JavaScript
SerenDB Auth for Next.js SerenDB Auth for React Vanilla TS Template
<GetStarted framework="JavaScript" envVars={`
SerenDB Auth environment variables for JavaScript/Node
STACK_PROJECT_ID=YOUR_NEON_AUTH_PROJECT_ID STACK_PUBLISHABLE_CLIENT_KEY=YOUR_NEON_AUTH_PUBLISHABLE_KEY STACK_SECRET_SERVER_KEY=YOUR_NEON_AUTH_SECRET_KEY
Your SerenDB connection string
DATABASE_URL=YOUR_NEON_CONNECTION_STRING } templateRepo="seren-auth-ts-template" setupSteps={
Install the JavaScript SDK
```bash npm install @stackframe/js ```
Use your environment variables
Paste the SerenDB Auth environment variables from Step 2 into your `.env` or `.env.local` file.
Configure SerenDB Auth client
```js // stack/server.js import { StackServerApp } from '@stackframe/js';
export const stackServerApp = new StackServerApp({ projectId: process.env.STACK_PROJECT_ID, publishableClientKey: process.env.STACK_PUBLISHABLE_CLIENT_KEY, secretServerKey: process.env.STACK_SECRET_SERVER_KEY, tokenStore: 'memory', }); ```
Test your integration
Create a test user in the Console (see Step 4) and copy its ID.
Create `src/test.ts`:
```ts import 'dotenv/config'; import { stackServerApp } from './stack/server.js';
async function main() { const user = await stackServerApp.getUser('YOUR_USER_ID_HERE'); console.log(user); }
main().catch(console.error); ```
You should see your test user's record printed in the console. `} />
Last updated