diff --git a/docs/docs/01-getting-started/01-setup.md b/docs/docs/01-getting-started/01-setup.md index acd953521..88ae06505 100644 --- a/docs/docs/01-getting-started/01-setup.md +++ b/docs/docs/01-getting-started/01-setup.md @@ -28,7 +28,7 @@ npm install @stackframe/stack STACK_SECRET_SERVER_KEY= ``` -2. Create `StackServerApp` in `lib/stack.ts`: +2. Create `StackServerApp` in `@lib/stack.ts`: ```tsx import "server-only"; diff --git a/docs/docs/01-getting-started/02-users.md b/docs/docs/01-getting-started/02-users.md index 7c1aa2643..cb4925a21 100644 --- a/docs/docs/01-getting-started/02-users.md +++ b/docs/docs/01-getting-started/02-users.md @@ -34,7 +34,7 @@ On Server Components, you don't need `useStackApp()`. Instead, you can just impo ```tsx import "server-only"; -import { stackApp } from "lib/stack"; +import { stackApp } from "@lib/stack"; export default async function MyComponent() { const user = await stackApp.getUser(); @@ -57,25 +57,24 @@ Call `useUser` (or `getUser`) with the `{ or: 'redirect' }` option to protect th ```tsx - "use client"; - import { useStackApp } from "@stackframe/stack"; + "use client"; + import { useStackApp } from "@stackframe/stack"; - export default function Protected() { - useUser({ or: 'redirect' }); - return

You can only see this if you are logged in

- } - ``` -
+ export default function Protected() { + useUser({ or: 'redirect' }); + return

You can only see this if you are logged in

+ } + ``` + - - ```tsx - import "server-only"; - import { useStackApp } from "@stackframe/stack"; + + ```tsx + import { useStackApp } from "@stackframe/stack"; - export default async function Protected() { - await stack.getUser({ or: 'redirect' }); - return

You can only see this if you are logged in

- } + export default async function Protected() { + await stack.getUser({ or: 'redirect' }); + return

You can only see this if you are logged in

+ } ```
@@ -86,15 +85,16 @@ Call `useUser` (or `getUser`) with the `{ or: 'redirect' }` option to protect th Stack automatically creates a user profile on sign-up. Let's create a page that displays this information. -Depending on whether you want to use a Client or Server Component, copy the following code into `app/page.tsx`: +If you want to use the client component version, create a new file with the following code and import it to `app/page.tsx`. If you want to use the server component version, paste the code directly into `app/page.tsx`. ```tsx 'use client'; -import { useStackApp } from "@stackframe/stack"; +import { useUser, useStackApp } from "@stackframe/stack"; export default function PageClient() { + const user = useUser(); const app = useStackApp(); return (
@@ -104,7 +104,7 @@ export default function PageClient() {

Welcome, {user.displayName}

Your e-mail: {user.primaryEmail}

Your e-mail verification status: {user.primaryEmailVerified}

- +
) : (
@@ -121,11 +121,10 @@ export default function PageClient() { ```tsx -import "server-only"; -import { stack } from "../lib/stack"; +import { stackApp } from "@/lib/stack"; export default async function Page() { - const user = await stack.getUser(); + const user = await stackApp.getUser(); return (

Home

@@ -133,14 +132,13 @@ export default async function Page() {

Welcome, {user.displayName}

Your e-mail: {user.primaryEmail}

-

Your e-mail verification status: {user.primaryEmailVerified}

- +

Sign Out

) : (

You are not logged in

- - +

Sign in

+

Sign up

)}
@@ -150,6 +148,8 @@ export default async function Page() {
+Now, if you visit http://localhost:3000, you should see the main page with user information or sign-in/ + ## Next steps Next, we will take a look at the actions that can be taken from the server-side. diff --git a/docs/docs/01-getting-started/03-server-side.md b/docs/docs/01-getting-started/03-server-side.md deleted file mode 100644 index be435b803..000000000 --- a/docs/docs/01-getting-started/03-server-side.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -sidebar_position: 1 ---- - -# Server-Side App - -Compared to `StackClientApp` (which is available to everyone with just a publishable client key), `StackServerApp` has some extra features. Particularly, it can be used to view & modify *other* users. Hence, it is crucial to keep the secret server key secure. - -## Next steps - -Next, we will try to understand what steps we need to go into production.