diff --git a/content/docs/shared-content/index.js b/content/docs/shared-content/index.js index 2c7d974cad..52de739fcf 100644 --- a/content/docs/shared-content/index.js +++ b/content/docs/shared-content/index.js @@ -21,22 +21,12 @@ const sharedMdxComponents = { AzureRegionsDeprecation: 'shared-content/azure-regions-deprecation', ConsumptionAccountApiDeprecation: 'shared-content/consumption-account-api-deprecation', NextjsProxyNote: 'shared-content/nextjs-proxy-note', - // neon-auth-sdk-shared - SdkOverview: 'shared-content/neon-auth-sdk-shared/overview', - SdkStackApp: 'shared-content/neon-auth-sdk-shared/objects/stack-app', // Common Neon Auth content GetStarted: 'shared-content/neon-auth-sdk-shared/get-started', // Types SdkUser: 'shared-content/neon-auth-sdk-shared/types/user', - SdkTeam: 'shared-content/neon-auth-sdk-shared/types/team', - SdkTeamUser: 'shared-content/neon-auth-sdk-shared/types/team-user', - SdkTeamProfile: 'shared-content/neon-auth-sdk-shared/types/team-profile', SdkProject: 'shared-content/neon-auth-sdk-shared/types/project', - SdkTeamPermission: 'shared-content/neon-auth-sdk-shared/types/team-permission', - SdkApiKey: 'shared-content/neon-auth-sdk-shared/types/api-key', - SdkContactChannel: 'shared-content/neon-auth-sdk-shared/types/contact-channel', // Hooks - SdkUseStackApp: 'shared-content/neon-auth-sdk-shared/hooks/use-stack-app', SdkUseUser: 'shared-content/neon-auth-sdk-shared/hooks/use-user', }; diff --git a/content/docs/shared-content/neon-auth-sdk-shared/get-started.md b/content/docs/shared-content/neon-auth-sdk-shared/get-started.md index 178c7513bc..af1f655143 100644 --- a/content/docs/shared-content/neon-auth-sdk-shared/get-started.md +++ b/content/docs/shared-content/neon-auth-sdk-shared/get-started.md @@ -1,5 +1,5 @@ --- -updatedOn: '2026-07-15T00:08:00.682Z' +updatedOn: '2026-07-27T17:22:37.262Z' --- diff --git a/content/docs/shared-content/neon-auth-sdk-shared/hooks/use-stack-app.md b/content/docs/shared-content/neon-auth-sdk-shared/hooks/use-stack-app.md deleted file mode 100644 index 92bdf17dd7..0000000000 --- a/content/docs/shared-content/neon-auth-sdk-shared/hooks/use-stack-app.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -updatedOn: '2025-07-23T17:03:23.000Z' ---- - -This is a reference for the `useStackApp` hook in the {sdkName} SDK. - -The `useStackApp` hook returns a `StackClientApp` object from the one that you provided in the [`StackProvider` component](../../components/stack-provider). If you want to learn more about the `StackClientApp` object, check out the [StackApp](../objects/stack-app) documentation. - -Example: - -```jsx -import { useStackApp } from '@stackframe/stack'; - -function MyComponent() { - const stackApp = useStackApp(); - return
Sign In URL: {stackApp.urls.signIn}
; -} -``` - -## Usage - -```jsx -import { useStackApp } from '@stackframe/stack'; - -function MyComponent() { - const stackApp = useStackApp(); - // ... -} -``` - -## Returns - -- `StackClientApp`: The main client-side SDK object. diff --git a/content/docs/shared-content/neon-auth-sdk-shared/hooks/use-user.md b/content/docs/shared-content/neon-auth-sdk-shared/hooks/use-user.md index 3ea3df0535..0da06ab774 100644 --- a/content/docs/shared-content/neon-auth-sdk-shared/hooks/use-user.md +++ b/content/docs/shared-content/neon-auth-sdk-shared/hooks/use-user.md @@ -1,5 +1,5 @@ --- -updatedOn: '2025-07-23T17:03:23.000Z' +updatedOn: '2026-07-27T17:22:37.262Z' --- This is a reference for the `useUser` hook in the {sdkName} SDK. diff --git a/content/docs/shared-content/neon-auth-sdk-shared/objects/stack-app.md b/content/docs/shared-content/neon-auth-sdk-shared/objects/stack-app.md deleted file mode 100644 index fdf0475316..0000000000 --- a/content/docs/shared-content/neon-auth-sdk-shared/objects/stack-app.md +++ /dev/null @@ -1,451 +0,0 @@ -This is a detailed reference for the client-side `StackApp` object in the {sdkName} SDK. If you're looking for a more high-level overview, please read the [respective page in the Concepts section](/docs/neon-auth/concepts/stack-app). - -## `StackClientApp` - -The main object for interacting with Stack Auth on the client. It provides methods for authentication, user management, and team management. - -Most commonly you get an instance of `StackClientApp` by calling [`useStackApp()`](../hooks/use-stack-app) in a Client Component. - -## Table of Contents - -
- type{" "}StackClientApp = {'{'}
- new(options): StackClientApp;
-
- getUser([options]): Promise<User>;
- useUser([options]): User;
- getProject(): Promise<Project>;
- useProject(): Project;
-
- signInWithOAuth(provider): void;
- signInWithCredential([options]): Promise<...>;
- signUpWithCredential([options]): Promise<...>;
- sendForgotPasswordEmail(email): Promise<...>;
- sendMagicLinkEmail(email): Promise<...>;
- {"};"} -
- -## Constructor - -Creates a new `StackClientApp` instance. - -Because each app creates a new connection to Stack Auth's backend, you should re-use existing instances wherever possible. - - -This object is not usually constructed directly. More commonly, you would construct a `StackServerApp` instead, pass it into a `StackProvider`, and then use `useStackApp()` hook to obtain a `StackClientApp`. - -The setup wizard does these steps for you, so you don't need to worry about it unless you are manually setting up Stack Auth. - -If you're building a client-only app and don't have a `SECRET_SERVER_KEY`, you can construct a `StackClientApp` directly. - - -### Parameters - -**options** (object) - -An object containing multiple properties. - -
-Show properties - -#### tokenStore (required) - -Where to store the user's session tokens. - -
-Show details - -##### Next.js - -In Next.js apps, use `"nextjs-cookie"` to store tokens in Next.js cookies. - -##### React - -In React apps, use `"cookie"` to store tokens in browser cookies. - -##### Possible values - -- `"nextjs-cookie"`: Uses Next.js cookies (Next.js only) -- `"cookie"`: Uses browser cookies (both React and Next.js) -- `"memory"`: Uses in-memory storage (both React and Next.js) -- `{ accessToken: string, refreshToken: string }`: Uses provided tokens (both React and Next.js) -- `Request`: Uses the provided request object (server-side only) -
- -#### baseUrl - -The base URL for {sdkName}'s API. Only override this if you are self-hosting. Defaults to `https://api.stack-auth.com`, unless overridden by the `NEXT_PUBLIC_STACK_API_URL` environment variable. - -#### projectId - -The ID of the project that the app is associated with, as found on the dashboard. Defaults to the value of the `NEXT_PUBLIC_STACK_PROJECT_ID` environment variable. - -#### publishableClientKey - -The publishable client key of the app, as found on the dashboard. Defaults to the value of the `NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY` environment variable. - -#### urls - -The URLs that {sdkName} uses to route and redirect. - -
-Properties -- `signIn`: The URL of the sign-in page -- `signUp`: The URL of the sign-up page -- `forgotPassword`: The URL of the forgot password page -
- -#### noAutomaticPrefetch - -Whether to disable automatic prefetching of user data. Defaults to `false`. - -
- -### Signature - -```typescript shouldWrap -declare new(options: { - tokenStore: "nextjs-cookie" | "cookie" | { accessToken: string, refreshToken: string } | Request; - baseUrl?: string; - projectId?: string; - publishableClientKey?: string; - urls: { - ... - }; - noAutomaticPrefetch?: boolean; -}): StackClientApp; -``` - -### Examples - -```typescript -const stackClientApp = new StackClientApp({ - tokenStore: 'nextjs-cookie', - baseUrl: 'https://api.stack-auth.com', - projectId: '123', - publishableClientKey: '123', - urls: { - home: '/', - }, -}); -``` - -```typescript -'use client'; - -function MyReactComponent() { - const stackClientApp = useStackApp(); -} -``` - -## `stackClientApp.getUser([options])` (#getuser) - -Gets the current user. - -### Parameters (#getuser-params) - -- `options`: An object containing multiple properties: - - `or`: What to do if the user is not found: - - `"return-null"`: Return null (default) - - `"redirect"`: Redirect to the sign-in page - - `"throw"`: Throw an error - -### Returns (#getuser-returns) - -`Promise`: The current user, or `null` if not signed in. If `or` is `"redirect"` or `"throw"`, never returns `null`. - -### Signature (#getuser-signature) - -```typescript shouldWrap -declare function getUser(options: { - or?: 'return-null' | 'redirect' | 'throw'; -}): Promise; -``` - -### Examples (#getuser-examples) - -```typescript -// Getting the current user -const userOrNull = await stackClientApp.getUser(); -console.log(userOrNull); // null if not signed in - -const user = await stackClientApp.getUser({ or: 'redirect' }); -console.log(user); // always defined; redirects to sign-in page if not signed in -``` - -## `stackClientApp.useUser([options])` (#useuser) - -Functionally equivalent to `getUser()`, but as a React hook. - -Equivalent to the `useUser()` standalone hook (which is an alias for `useStackApp().useUser()`). - -### Parameters (#useuser-params) - -- `options`: An object containing multiple properties: - - `or`: What to do if the user is not found: - - "return-null": Return null (default) - - "redirect": Redirect to the sign-in page - - "throw": Throw an error - -### Returns (#useuser-returns) - -`CurrentUser | null`: The current user, or `null` if not signed in. If `or` is "redirect" or "throw", never returns `null`. - -### Signature (#useuser-signature) - -```typescript shouldWrap -declare function useUser(options: { - or?: 'return-null' | 'redirect' | 'throw'; -}): CurrentUser | null; -``` - -### Examples (#useuser-examples) - -```jsx -// Displaying the current user's username -'use client'; - -function MyReactComponent() { - // useUser(...) is an alias for useStackApp().useUser(...) - const user = useUser(); - return user ?
Hello, {user.name}
:
Not signed in
; -} - -// Redirecting vs. not redirecting -('use client'); - -function MyReactComponent() { - const user = useUser(); - console.log(user); // null if not signed in - - const user = useUser({ or: 'redirect' }); // redirects to sign-in page if necessary - console.log(user); // always defined - - const user = useUser({ or: 'throw' }); // throws an error if not signed in - console.log(user); // always defined -} - -// Protecting a page client-side -('use client'); - -function MyProtectedComponent() { - // Note: This component is protected on the client-side. - // It does not protect against malicious users, since - // they can just comment out the `useUser` call in their - // browser's developer console. - // - // The purpose of client-side protection is to redirect - // unauthenticated users to the sign-in page, not to - // hide secret information from them. - // - // For more information on protecting pages and how to - // protect a page server-side or in the middleware, see - // the Stack Auth documentation: - // https://docs.stack-auth.com/getting-started/users#protecting-a-page - - useUser({ or: 'redirect' }); - return
You can only see this if you are authenticated
; -} -``` - -## `stackClientApp.getProject()` (#getproject) - -Get the current project. - -### Returns (#getproject-returns) - -`Promise`: The current project. - -### Signature (#getproject-signature) - -```typescript shouldWrap -declare function getProject(): Promise; -``` - -### Examples (#getproject-examples) - -```typescript -const project = await stackClientApp.getProject(); -console.log(project); -``` - -## `stackClientApp.useProject()` - -Functionally equivalent to `getProject()`, but as a React hook. - -## `stackClientApp.signInWithOAuth(provider)` (#signinwithoauth) - -Sign in with an OAuth provider. - -### Parameters (#signinwithoauth-params) - -- `provider`: The OAuth provider to use. - -### Returns (#signinwithoauth-returns) - -`Promise>`: A promise that resolves to a `Result` object. - -### Signature (#signinwithoauth-signature) - -```typescript shouldWrap -declare function signInWithOAuth( - provider: string -): Promise>; -``` - -### Examples (#signinwithoauth-examples) - -```typescript -const result = await stackClientApp.signInWithOAuth('google'); - -if (result.status === 'error') { - console.error('Sign in failed', result.error.message); -} -``` - -## `stackClientApp.signInWithCredential(options)` (#signinwithcredential) - -Sign in with email and password. - -### Parameters (#signinwithcredential-params) - -- `options`: An object containing multiple properties: - - `email`: The email of the user to sign in as - - `password`: The password of the user to sign in as - -### Returns (#signinwithcredential-returns) - -`Promise>`: A promise that resolves to a `Result` object. - -### Signature (#signinwithcredential-signature) - -```typescript shouldWrap -declare function signInWithCredential(options: { - email: string; - password: string; -}): Promise>; -``` - -### Examples (#signinwithcredential-examples) - -```typescript -const result = await stackClientApp.signInWithCredential({ - email: 'test@example.com', - password: 'password', -}); - -if (result.status === 'error') { - console.error('Sign in failed', result.error.message); -} -``` - -## `stackClientApp.signUpWithCredential(options)` (#signupwithcredential) - -Sign up with email and password. - -### Parameters (#signupwithcredential-params) - -- `options`: An object containing multiple properties: - - `email`: The email of the user to sign up as - - `password`: The password of the user to sign up as - -### Returns (#signupwithcredential-returns) - -`Promise>`: A promise that resolves to a `Result` object. - -### Signature (#signupwithcredential-signature) - -```typescript shouldWrap -declare function signUpWithCredential(options: { - email: string; - password: string; -}): Promise< - Result< - undefined, - KnownErrors['UserWithEmailAlreadyExists'] | KnownErrors['PasswordRequirementsNotMet'] - > ->; -``` - -### Examples (#signupwithcredential-examples) - -```typescript -const result = await stackClientApp.signUpWithCredential({ - email: 'test@example.com', - password: 'password', -}); - -if (result.status === 'error') { - console.error('Sign up failed', result.error.message); -} -``` - -## `stackClientApp.sendForgotPasswordEmail(email)` (#sendforgotpasswordemail) - -Send a forgot password email to an email address. - -### Parameters (#sendforgotpasswordemail-params) - -- `email`: The email of the user to send the forgot password email to. - -### Returns (#sendforgotpasswordemail-returns) - -`Promise>`: A promise that resolves to a `Result` object. - -### Signature (#sendforgotpasswordemail-signature) - -```typescript shouldWrap -declare function sendForgotPasswordEmail( - email: string -): Promise>; -``` - -### Examples (#sendforgotpasswordemail-examples) - -```typescript -const result = await stackClientApp.sendForgotPasswordEmail('test@example.com'); - -if (result.status === 'success') { - console.log('Forgot password email sent'); -} else { - console.error('Failed to send forgot password email', result.error.message); -} -``` - -## `stackClientApp.sendMagicLinkEmail(email)` (#sendmagiclinkeemail) - -Send a magic link/OTP sign-in email to an email address. - -### Parameters (#sendmagiclinkeemail-params) - -- `email`: The email of the user to send the magic link email to. - -### Returns (#sendmagiclinkeemail-returns) - -`Promise>`: A promise that resolves to a `Result` object. - -### Signature (#sendmagiclinkeemail-signature) - -```typescript shouldWrap -declare function sendMagicLinkEmail( - email: string -): Promise>; -``` - -### Examples (#sendmagiclinkeemail-examples) - -```typescript -const result = await stackClientApp.sendMagicLinkEmail('test@example.com'); -``` diff --git a/content/docs/shared-content/neon-auth-sdk-shared/types/api-key.md b/content/docs/shared-content/neon-auth-sdk-shared/types/api-key.md deleted file mode 100644 index 2b5b6ab7f7..0000000000 --- a/content/docs/shared-content/neon-auth-sdk-shared/types/api-key.md +++ /dev/null @@ -1,161 +0,0 @@ -This is a reference for the `ApiKey` type in the {sdkName} SDK. - -Represents an API key for a user or project in Managed Better Auth. - -On this page: - -- [`ApiKey`](#apikey) -- Types: - - [`UserApiKey`](#userapikey) - - [`TeamApiKey`](#teamapikey) - -## `ApiKey` - -API keys provide a way for users to authenticate with your backend services without using their primary credentials. They can be created for individual users or for teams, allowing programmatic access to your application. - -API keys can be obtained through: - -- [`user.createApiKey()`](/docs/neon-auth/sdk/{slug}/types/user#currentusercreateapikeyoptions) -- [`user.listApiKeys()`](/docs/neon-auth/sdk/{slug}/types/user#currentuserlistapikeys) -- [`user.useApiKeys()`](/docs/neon-auth/sdk/{slug}/types/user#currentuseruseapikeys) (React hook) -- [`team.createApiKey()`](/docs/neon-auth/sdk/{slug}/types/team#teamcreateapikeyoptions) -- [`team.listApiKeys()`](/docs/neon-auth/sdk/{slug}/types/team#teamlistapikeys) -- [`team.useApiKeys()`](/docs/neon-auth/sdk/{slug}/types/team#teamuseapikeys) (React hook) - -### Type Definition - -```typescript -type ApiKey = { - id: string; - description: string; - expiresAt?: Date; - manuallyRevokedAt: Date | null; - createdAt: Date; - value: IsFirstView extends true ? string : { lastFour: string }; - - // User or Team properties based on Type - ...(Type extends "user" ? { - type: "user"; - userId: string; - } : { - type: "team"; - teamId: string; - }) - - // Methods - isValid(): boolean; - whyInvalid(): "manually-revoked" | "expired" | null; - revoke(): Promise; - update(options): Promise; -}; -``` - -### `apiKey.id` - -The unique identifier for this API key. - -```typescript -declare const id: string; -``` - -### `apiKey.description` - -A human-readable description of the API key's purpose. - -```typescript -declare const description: string; -``` - -### `apiKey.expiresAt` - -The date and time when this API key will expire. If not set, the key does not expire. - -```typescript -declare const expiresAt?: Date; -``` - -### `apiKey.manuallyRevokedAt` - -The date and time when this API key was manually revoked. If null, the key has not been revoked. - -```typescript -declare const manuallyRevokedAt: Date | null; -``` - -### `apiKey.createdAt` - -The date and time when this API key was created. - -```typescript -declare const createdAt: Date; -``` - -### `apiKey.value` - -The value of the API key. When the key is first created, this is the full API key string. After that, only the last four characters are available for security reasons. - -```typescript -// On first creation -declare const value: string; - -// On subsequent retrievals -declare const value: { lastFour: string }; -``` - -### `apiKey.userId` - -For user API keys, the ID of the user that owns this API key. - -```typescript -declare const userId: string; -``` - -### `apiKey.teamId` - -For team API keys, the ID of the team that owns this API key. - -```typescript -declare const teamId: string; -``` - -### `apiKey.isValid()` - -Checks if the API key is still valid (not expired and not revoked). - -```typescript -declare function isValid(): boolean; -``` - -### `apiKey.whyInvalid()` - -Returns a reason why the API key is invalid, or null if it is valid. - -```typescript -declare function whyInvalid(): 'manually-revoked' | 'expired' | null; -``` - -### `apiKey.revoke()` - -Revokes the API key. - -```typescript -declare function revoke(): Promise; -``` - -### `apiKey.update(options)` - -Updates the API key. - -#### Parameters - -- `options`: An object containing properties for updating. - - `description`: The new description of the API key. - - `expiresAt`: The new expiration date of the API key. - -#### Returns - -`Promise` - -```typescript -declare function update(options: { description?: string; expiresAt?: Date }): Promise; -``` diff --git a/content/docs/shared-content/neon-auth-sdk-shared/types/contact-channel.md b/content/docs/shared-content/neon-auth-sdk-shared/types/contact-channel.md deleted file mode 100644 index c1434e0f41..0000000000 --- a/content/docs/shared-content/neon-auth-sdk-shared/types/contact-channel.md +++ /dev/null @@ -1,156 +0,0 @@ -This is a reference for the `ContactChannel` type in the {sdkName} SDK. - -Represents a contact method (email, phone, etc.) for a user. - -`ContactChannel` represents a user's contact information, such as an email address or phone number. Some auth methods, like OTP/magic link or password, use contact channels for authentication. - -On this page: - -- [`ContactChannel`](#contactchannel) - -## `ContactChannel` - -Basic information about a contact channel, as seen by a user themselves. - -Usually obtained by calling [`user.listContactChannels()`](/docs/neon-auth/sdk/nextjs/types/user#currentuserlistcontactchannels) -or [`user.useContactChannels()`](/docs/neon-auth/sdk/nextjs/types/user#currentuserusecontactchannels). - -### Type Definition - -```typescript -type ContactChannel = { - id: string; - value: string; - type: 'email'; - isPrimary: boolean; - isVerified: boolean; - usedForAuth: boolean; - - sendVerificationEmail(): Promise; - update(options): Promise; - delete(): Promise; -}; -``` - -### `contactChannel.id` - -The id of the contact channel as a `string`. - -```typescript -declare const id: string; -``` - -### `contactChannel.value` - -The value of the contact channel. If type is `"email"`, this is an email address. - -```typescript -declare const value: string; -``` - -### `contactChannel.type` - -The type of the contact channel. Currently always `"email"`. - -```typescript -declare const type: 'email'; -``` - -### `contactChannel.isPrimary` - -Indicates whether the contact channel is the user's primary contact channel. If an email is set to primary, it will be the value on the `user.primaryEmail` field. - -```typescript -declare const isPrimary: boolean; -``` - -### `contactChannel.isVerified` - -Indicates whether the contact channel is verified. - -```typescript -declare const isVerified: boolean; -``` - -### `contactChannel.usedForAuth` - -Indicates whether the contact channel is used for authentication. If set to `true`, the user can use this contact channel with OTP or password to sign in. - -```typescript -declare const usedForAuth: boolean; -``` - -### `contactChannel.sendVerificationEmail()` - -Sends a verification email to this contact channel. Once the user clicks the verification link in the email, the contact channel will be marked as verified. - -#### Parameters - -None. - -#### Returns - -`Promise` - -```typescript -declare function sendVerificationEmail(): Promise; -``` - -#### Example - -```typescript -await contactChannel.sendVerificationEmail(); -``` - -### `contactChannel.update(options)` - -Updates the contact channel. After updating the value, the contact channel will be marked as unverified. - -#### Parameters - -- `options`: An object containing properties for updating. - - `value`: The new value of the contact channel. - - `type`: The new type of the contact channel. Currently always `"email"`. - - `usedForAuth`: Indicates whether the contact channel is used for authentication. - - `isPrimary`: Indicates whether the contact channel is the user's primary contact channel. - -#### Returns - -`Promise` - -```typescript -declare function update(options: { - value?: string; - type?: 'email'; - usedForAuth?: boolean; - isPrimary?: boolean; -}): Promise; -``` - -#### Example - -```typescript -await contactChannel.update({ value: 'new-email@example.com' }); -``` - -### `contactChannel.delete()` - -Deletes the contact channel. - -#### Parameters - -None. - -#### Returns - -`Promise` - -```typescript -declare function delete(): Promise; -``` - -#### Example - -```typescript -await contactChannel.delete(); -``` diff --git a/content/docs/shared-content/neon-auth-sdk-shared/types/team-permission.md b/content/docs/shared-content/neon-auth-sdk-shared/types/team-permission.md deleted file mode 100644 index ce6570c6e3..0000000000 --- a/content/docs/shared-content/neon-auth-sdk-shared/types/team-permission.md +++ /dev/null @@ -1,23 +0,0 @@ -This is a reference for the `TeamPermission` type in the {sdkName} SDK. - -## TeamPermission - -The `TeamPermission` object represents a permission that a user has within a team in Managed Better Auth. Currently, it contains only an `id` to specify the permission. - -You can get `TeamPermission` objects by calling functions such as `user.getPermission(...)` or `user.listPermissions()`. - -## Type of contents - -```typescript -type TeamPermission = { - id: string; -}; -``` - -### teamPermission.id - -The identifier of the permission as a string. - -```typescript -declare const id: string; -``` diff --git a/content/docs/shared-content/neon-auth-sdk-shared/types/team-profile.md b/content/docs/shared-content/neon-auth-sdk-shared/types/team-profile.md deleted file mode 100644 index 85b26db5f8..0000000000 --- a/content/docs/shared-content/neon-auth-sdk-shared/types/team-profile.md +++ /dev/null @@ -1,47 +0,0 @@ -This is a detailed reference for the `TeamProfile` and `ServerTeamProfile` objects in the {sdkName} SDK. - -On this page: - -- [TeamProfile](#teamprofile) -- [ServerTeamProfile](#serverteamprofile) - -## `TeamProfile` - -The `TeamProfile` object represents the profile of a user within the context of a team. It includes the user's profile information specific to the team and can be accessed through the `teamUser.teamProfile` property on a `TeamUser` object. - -### Table of Contents - -```typescript -type TeamProfile = { - displayName: string | null; - profileImageUrl: string | null; -}; -``` - -### `teamProfile.displayName` - -The display name of the user within the team context as a `string` or `null` if no display name is set. - -```typescript -declare const displayName: string | null; -``` - -### `teamProfile.profileImageUrl` - -The profile image URL of the user within the team context as a `string`, or `null` if no profile image is set. - -```typescript -declare const profileImageUrl: string | null; -``` - -## `ServerTeamProfile` - -The `ServerTeamProfile` object is currently the same as `TeamProfile`. - -### Table of Contents - -```typescript -type ServerTeamProfile = - // Inherits all functionality from TeamProfile - TeamProfile; -``` diff --git a/content/docs/shared-content/neon-auth-sdk-shared/types/team-user.md b/content/docs/shared-content/neon-auth-sdk-shared/types/team-user.md deleted file mode 100644 index d679565d3d..0000000000 --- a/content/docs/shared-content/neon-auth-sdk-shared/types/team-user.md +++ /dev/null @@ -1,63 +0,0 @@ -This is a detailed reference for the `TeamUser` and `ServerTeamUser` objects in the {sdkName} SDK. - -On this page: - -- [TeamUser](#teamuser) -- [ServerTeamUser](#serverteamuser) - -## `TeamUser` - -The `TeamUser` object is used on the client side to represent a user in the context of a team, providing minimal information about the user, including their ID and team-specific profile. - -It is usually obtained by calling `team.useUsers()` or `team.listUsers()` on a [`Team` object](../types/team). - -### Table of Contents - -```typescript -type TeamUser = { - id: string; - teamProfile: TeamProfile; -}; -``` - -### `teamUser.id` - -The ID of the user. - -```typescript -declare const id: string; -``` - -### `teamUser.teamProfile` - -The team profile of the user as a `TeamProfile` object. - -```typescript -declare const teamProfile: TeamProfile; -``` - -## `ServerTeamUser` - -The `ServerTeamUser` object is used on the server side to represent a user within a team. Besides the team profile, it also includes all the functionality of a [`ServerUser`](../types/user). - -It is usually obtained by calling `serverTeam.listUsers()` on a [`ServerTeam` object](../types/team). - -### Table of Contents - -```typescript -type ServerTeamUser = - // Inherits all functionality from TeamUser - TeamUser & - // Inherits all functionality from ServerUser - ServerUser & { - teamProfile: ServerTeamProfile; - }; -``` - -### `serverTeamUser.teamProfile` - -The team profile of the user as a `ServerTeamProfile` object. - -```typescript -declare const teamProfile: ServerTeamProfile; -``` diff --git a/content/docs/shared-content/neon-auth-sdk-shared/types/team.md b/content/docs/shared-content/neon-auth-sdk-shared/types/team.md deleted file mode 100644 index e4bdfd8460..0000000000 --- a/content/docs/shared-content/neon-auth-sdk-shared/types/team.md +++ /dev/null @@ -1,233 +0,0 @@ -This is a reference for the `Team` type in the {sdkName} SDK. - -Represents a team in Managed Better Auth. - -On this page: - -- [`Team`](#team) -- Types: - - [`TeamUser`](#teamuser) - - [`TeamApiKey`](#teamapikey) - -## `Team` - -A `Team` object contains basic information and functions about a team, to the extent of which a member of the team would have access to it. - -You can get `Team` objects with the `user.useTeams()` or `user.listTeams()` functions. The created team will then inherit the permissions of that user; for example, the `team.update(...)` function can only succeed if the user is allowed to make updates to the team. - -### Type Definition - -```typescript -type Team = { - id: string; - displayName: string; - profileImageUrl: string | null; - clientMetadata: Json; - clientReadOnlyMetadata: Json; - - update(data): Promise; - inviteUser(options): Promise; - listUsers(): Promise; - useUsers(): TeamUser[]; - listInvitations(): Promise<{ ... }[]>; - useInvitations(): { ... }[]; - - createApiKey(options): Promise; - listApiKeys(): Promise; - useApiKeys(): TeamApiKey[]; -}; -``` - -### `team.id` - -The team ID as a `string`. This value is always unique. - -```typescript -declare const id: string; -``` - -### `team.displayName` - -The display name of the team as a `string`. - -```typescript -declare const displayName: string; -``` - -### `team.profileImageUrl` - -The profile image URL of the team as a `string`, or `null` if no profile image is set. - -```typescript -declare const profileImageUrl: string | null; -``` - -### `team.clientMetadata` - -The client metadata of the team as a `Json` object. - -```typescript -declare const clientMetadata: Json; -``` - -### `team.clientReadOnlyMetadata` - -The client read-only metadata of the team as a `Json` object. - -```typescript -declare const clientReadOnlyMetadata: Json; -``` - -### `team.update(data)` - -Updates the team information. - -Note that this operation requires the current user to have the `$update_team` permission. If the user lacks this permission, an error will be thrown. - -#### Parameters - -- `data`: An object containing the fields to update. - - `displayName`: The display name of the team. - - `profileImageUrl`: The profile image URL of the team. - - `clientMetadata`: The client metadata of the team. - -#### Returns - -`Promise` - -```typescript -declare function update(options: { - displayName?: string; - profileImageUrl?: string | null; - clientMetadata?: Json; -}): Promise; -``` - -#### Example - -```typescript -await team.update({ - displayName: 'New Team Name', - profileImageUrl: 'https://example.com/profile.png', - clientMetadata: { - address: '123 Main St, Anytown, USA', - }, -}); -``` - -### `team.inviteUser(options)` - -Sends an invitation email to a user to join the team. - -Note that this operation requires the current user to have the `$invite_members` permission. If the user lacks this permission, an error will be thrown. - -An invitation email containing a magic link will be sent to the specified user. If the user has an existing account, they will be automatically added to the team upon clicking the link. For users without an account, the link will guide them through the sign-up process before adding them to the team. - -#### Parameters - -- `options`: An object containing multiple properties. - - `email`: The email of the user to invite. - - `callbackUrl`: The URL where users will be redirected after accepting the team invitation. - Required when calling `inviteUser()` in the server environment since the URL cannot be automatically determined. - Example: `https://your-app-url.com/handler/team-invitation` - -#### Returns - -`Promise` - -```typescript -declare function inviteUser(options: { email: string; callbackUrl?: string }): Promise; -``` - -### `team.listUsers()` - -Lists all users in the team. - -#### Returns - -`Promise` - -```typescript -declare function listUsers(): Promise; -``` - -### `team.useUsers()` - -A React hook that returns all users in the team. - -#### Returns - -`TeamUser[]` - -```typescript -declare function useUsers(): TeamUser[]; -``` - -### `team.listInvitations()` - -Lists all pending invitations to the team. - -#### Returns - -`Promise<{ ... }[]>` - -```typescript -declare function listInvitations(): Promise<{ ... }[]>; -``` - -### `team.useInvitations()` - -A React hook that returns all pending invitations to the team. - -#### Returns - -`{ ... }[]` - -```typescript -declare function useInvitations(): { ... }[]; -``` - -### `team.createApiKey(options)` - -Creates a new API key for the team. - -#### Parameters - -- `options`: An object containing the API key configuration. - - `description`: A description of the API key's purpose. - - `expiresAt`: Optional expiration date for the API key. - -#### Returns - -`Promise` - -```typescript -declare function createApiKey(options: { - description: string; - expiresAt?: Date; -}): Promise; -``` - -### `team.listApiKeys()` - -Lists all API keys for the team. - -#### Returns - -`Promise` - -```typescript -declare function listApiKeys(): Promise; -``` - -### `team.useApiKeys()` - -A React hook that returns all API keys for the team. - -#### Returns - -`TeamApiKey[]` - -```typescript -declare function useApiKeys(): TeamApiKey[]; -```