diff --git a/docs/fern/docs/pages/sdk/account-settings.mdx b/docs/fern/docs/pages/sdk/account-settings.mdx new file mode 100644 index 0000000000..d034074956 --- /dev/null +++ b/docs/fern/docs/pages/sdk/account-settings.mdx @@ -0,0 +1,23 @@ +--- +title: AccountSettings +--- + +# AccountSettings + +Renders an account settings component with various sections. Can be displayed as a full page or embedded. + +## Parameters + +- `fullPage` (optional): `boolean` - Determines whether to render the component as a full page. Defaults to `false`. + +## Example + +```tsx +import { AccountSettings } from '@stackframe/stack'; + +// Render as embedded component + + +// Render as full page + +``` \ No newline at end of file diff --git a/docs/fern/docs/pages/sdk/auth-page.mdx b/docs/fern/docs/pages/sdk/auth-page.mdx new file mode 100644 index 0000000000..000ed4dfdd --- /dev/null +++ b/docs/fern/docs/pages/sdk/auth-page.mdx @@ -0,0 +1,35 @@ +--- +title: AuthPage +--- + +# AuthPage + +Renders an authentication page for sign-in or sign-up, with various configuration options. + +## Parameters + +- `fullPage` (optional): `boolean` - Whether to render the auth page in full-page mode. Default is `false`. +- `type`: `'sign-in' | 'sign-up'` - The type of authentication page to render. +- `automaticRedirect` (optional): `boolean` - Whether to automatically redirect after successful authentication. +- `mockProject` (optional): `object` - Mock project configuration for testing purposes. + - `config`: `object` + - `signUpEnabled`: `boolean` + - `credentialEnabled`: `boolean` + - `magicLinkEnabled`: `boolean` + - `oauthProviders`: `{ id: string }[]` + +## Example + +```tsx +import { AuthPage } from '@stackframe/stack'; + +// Basic usage + + +// Full page sign-up with automatic redirect + +``` \ No newline at end of file diff --git a/docs/fern/docs/pages/sdk/credential-sign-in.mdx b/docs/fern/docs/pages/sdk/credential-sign-in.mdx new file mode 100644 index 0000000000..0d659d727b --- /dev/null +++ b/docs/fern/docs/pages/sdk/credential-sign-in.mdx @@ -0,0 +1,26 @@ +--- +title: CredentialSignIn +--- + +# CredentialSignIn + +A React component for handling user sign-in with email and password credentials. It provides a form with email and password inputs, error handling, and submission functionality. + +## Parameters + +This component doesn't accept any parameters. + +## Example + +```tsx +import { CredentialSignIn } from '@stackframe/stack'; + +function SignInPage() { + return ( +
+

Sign In

+ +
+ ); +} +``` \ No newline at end of file diff --git a/docs/fern/docs/pages/sdk/credential-sign-up.mdx b/docs/fern/docs/pages/sdk/credential-sign-up.mdx new file mode 100644 index 0000000000..55ad9b55a8 --- /dev/null +++ b/docs/fern/docs/pages/sdk/credential-sign-up.mdx @@ -0,0 +1,26 @@ +--- +title: CredentialSignUp +--- + +# CredentialSignUp + +Renders a sign-up form component with email and password fields. Handles form submission and validation. + +## Parameters + +This component does not accept any parameters. + +## Example + +```tsx +import { CredentialSignUp } from '@stackframe/stack'; + +function SignUpPage() { + return ( +
+

Sign Up

+ +
+ ); +} +``` \ No newline at end of file diff --git a/docs/fern/docs/pages/sdk/email-verification.mdx b/docs/fern/docs/pages/sdk/email-verification.mdx new file mode 100644 index 0000000000..db568029d8 --- /dev/null +++ b/docs/fern/docs/pages/sdk/email-verification.mdx @@ -0,0 +1,27 @@ +--- +title: EmailVerification +--- + +# EmailVerification + +Renders an email verification component based on the provided verification code and page layout preference. + +## Parameters + +- `searchParams` (optional): `Record` - An object containing search parameters. It should have a `code` property for the verification code. +- `fullPage` (optional): `boolean` - Determines whether to render the component in full-page mode. Default is `false`. + +## Example + +```tsx +import { EmailVerification } from '@stackframe/stack'; + +// Basic usage + + +// With search params and full-page mode + +``` \ No newline at end of file diff --git a/docs/fern/docs/pages/sdk/forgot-password.mdx b/docs/fern/docs/pages/sdk/forgot-password.mdx new file mode 100644 index 0000000000..a4d5869228 --- /dev/null +++ b/docs/fern/docs/pages/sdk/forgot-password.mdx @@ -0,0 +1,23 @@ +--- +title: ForgotPassword +--- + +# ForgotPassword + +A component for handling the forgot password functionality. It displays different views based on the user's state and whether a reset email has been sent. + +## Parameters + +- `fullPage` (optional): `boolean` - Determines if the component should be displayed in full-page mode. Defaults to `false`. + +## Example + +```tsx +import { ForgotPassword } from '@stackframe/stack'; + +// Default usage + + +// Full-page mode + +``` \ No newline at end of file diff --git a/docs/fern/docs/pages/sdk/magic-link-sign-in.mdx b/docs/fern/docs/pages/sdk/magic-link-sign-in.mdx new file mode 100644 index 0000000000..4b90e9a976 --- /dev/null +++ b/docs/fern/docs/pages/sdk/magic-link-sign-in.mdx @@ -0,0 +1,26 @@ +--- +title: MagicLinkSignIn +--- + +# MagicLinkSignIn + +A React component for magic link sign-in functionality. It handles form submission and displays the sign-in form. + +## Parameters + +This component doesn't accept any parameters. + +## Example + +```tsx +import { MagicLinkSignIn } from '@stackframe/stack'; + +function SignInPage() { + return ( +
+

Sign In

+ +
+ ); +} +``` \ No newline at end of file diff --git a/docs/fern/docs/pages/sdk/message-card.mdx b/docs/fern/docs/pages/sdk/message-card.mdx new file mode 100644 index 0000000000..2a8176eae1 --- /dev/null +++ b/docs/fern/docs/pages/sdk/message-card.mdx @@ -0,0 +1,37 @@ +--- +title: MessageCard +--- + +# MessageCard + +A component for displaying a card with a title, optional content, and action buttons. + +## Parameters + +- `title`: `string` - The title of the message card. +- `children` (optional): `React.ReactNode` - The content to be displayed in the card. +- `fullPage` (optional): `boolean` - Whether to display the card in full-page mode. Default is `false`. +- `primaryButtonText` (optional): `string` - The text for the primary action button. +- `primaryAction` (optional): `() => Promise | void` - The function to be called when the primary button is clicked. +- `secondaryButtonText` (optional): `string` - The text for the secondary action button. +- `secondaryAction` (optional): `() => Promise | void` - The function to be called when the secondary button is clicked. + +## Example + +```tsx +import { MessageCard } from '@stackframe/stack'; + +function ExampleComponent() { + return ( + console.log('Primary action clicked')} + secondaryButtonText='Learn More' + secondaryAction={() => console.log('Secondary action clicked')} + > +

This is an example message card.

+
+ ); +} +``` \ No newline at end of file diff --git a/docs/fern/docs/pages/sdk/oauth-button-group.mdx b/docs/fern/docs/pages/sdk/oauth-button-group.mdx new file mode 100644 index 0000000000..e8e3b007cd --- /dev/null +++ b/docs/fern/docs/pages/sdk/oauth-button-group.mdx @@ -0,0 +1,32 @@ +--- +title: OAuthButtonGroup +--- + +# OAuthButtonGroup + +Renders a group of OAuth buttons for sign-in or sign-up functionality. + +## Parameters + +- `type`: `'sign-in' | 'sign-up'` - Specifies whether the buttons are for sign-in or sign-up. +- `mockProject` (optional): `{ config: { oauthProviders: { id: string }[] } }` - Mocked project data for testing purposes. + +## Example + +```tsx +import { OAuthButtonGroup } from '@stackframe/stack'; + +// Basic usage + + +// With mock project data +const mockProject = { + config: { + oauthProviders: [ + { id: 'google' }, + { id: 'github' } + ] + } +}; + +``` \ No newline at end of file diff --git a/docs/fern/docs/pages/sdk/oauth-button.mdx b/docs/fern/docs/pages/sdk/oauth-button.mdx new file mode 100644 index 0000000000..b7bdb1e823 --- /dev/null +++ b/docs/fern/docs/pages/sdk/oauth-button.mdx @@ -0,0 +1,24 @@ +--- +title: OAuthButton +--- + +# OAuthButton + +A customizable OAuth button component for sign-in or sign-up using various providers. + +## Parameters + +- `provider`: `string` - The OAuth provider (e.g., 'google', 'github', 'facebook', 'microsoft', 'spotify'). +- `type`: `'sign-in' | 'sign-up'` - Determines whether the button is for sign-in or sign-up. + +## Example + +```tsx +import { OAuthButton } from '@stackframe/stack'; + +// Sign-in button for Google + + +// Sign-up button for GitHub + +``` \ No newline at end of file diff --git a/docs/fern/docs/pages/sdk/password-reset.mdx b/docs/fern/docs/pages/sdk/password-reset.mdx new file mode 100644 index 0000000000..3ef17fd690 --- /dev/null +++ b/docs/fern/docs/pages/sdk/password-reset.mdx @@ -0,0 +1,27 @@ +--- +title: PasswordReset +--- + +# PasswordReset + +A React component for handling password reset functionality. It validates the reset code and renders appropriate messages or the reset form. + +## Parameters + +- `searchParams`: `Record` - An object containing search parameters, including the reset code. +- `fullPage` (optional): `boolean` - Determines if the component should render in full-page mode. Defaults to `false`. + +## Example + +```tsx +import { PasswordReset } from '@stackframe/stack'; + +function PasswordResetPage({ searchParams }) { + return ; +} + +// Without fullPage option +function PasswordResetWidget({ searchParams }) { + return ; +} +``` \ No newline at end of file diff --git a/docs/fern/docs/pages/sdk/selected-team-switcher.mdx b/docs/fern/docs/pages/sdk/selected-team-switcher.mdx new file mode 100644 index 0000000000..14371246a7 --- /dev/null +++ b/docs/fern/docs/pages/sdk/selected-team-switcher.mdx @@ -0,0 +1,30 @@ +--- +title: SelectedTeamSwitcher +--- + +# SelectedTeamSwitcher + +A component for switching between teams in the Stack app. It displays a dropdown of available teams and handles team selection. + +## Parameters + +- `props`: `SelectedTeamSwitcherProps` - An object containing the following properties: + - `selectedTeam` (optional): The currently selected team. + - `noUpdateSelectedTeam` (optional): `boolean` - If true, prevents updating the selected team in the user's settings. + - `urlMap` (optional): `(team: Team) => string` - A function to generate a URL for the selected team. + +## Example + +```tsx +import { SelectedTeamSwitcher } from '@stackframe/stack'; + +function TeamSelector() { + return ( + `/team/${team.id}`} + /> + ); +} +``` \ No newline at end of file diff --git a/docs/fern/docs/pages/sdk/sign-in.mdx b/docs/fern/docs/pages/sdk/sign-in.mdx index ed3d315661..84dbc20c3e 100644 --- a/docs/fern/docs/pages/sdk/sign-in.mdx +++ b/docs/fern/docs/pages/sdk/sign-in.mdx @@ -1,14 +1,23 @@ --- -slug: sdk/sign-in +title: SignIn --- -The `SignIn` component is a pre-built UI element that displays all available sign-in methods as configured in the Stack dashboard. +# SignIn - - This component does not redirect a signed-in user. To achieve automatic redirection for signed-in users, you can use the `useUser` hook to check the user's sign-in status and perform the redirection if necessary. - +Renders a sign-in page component. Can be displayed as a full page or embedded within other content. -![Sign In Component](../imgs/sign-in.png) +## Parameters -## Props -- `fullPage` (boolean): Determines whether the component should occupy the full page. Default is `false`. \ No newline at end of file +- `fullPage` (optional): `boolean` - Determines if the sign-in page should be rendered as a full page. Defaults to `false`. + +## Example + +```tsx +import { SignIn } from '@stackframe/stack'; + +// Embedded sign-in +const EmbeddedSignIn = () => ; + +// Full-page sign-in +const FullPageSignIn = () => ; +``` \ No newline at end of file diff --git a/docs/fern/docs/pages/sdk/sign-up.mdx b/docs/fern/docs/pages/sdk/sign-up.mdx index f1b94df678..072b7867d6 100644 --- a/docs/fern/docs/pages/sdk/sign-up.mdx +++ b/docs/fern/docs/pages/sdk/sign-up.mdx @@ -1,14 +1,23 @@ --- -slug: sdk/sign-up +title: SignUp --- -The `SignUp` component is a pre-built component that displays all the sign up methods available based on the Stack dashboard configuration. +# SignUp - - This component does not redirect a signed-in user. To achieve automatic redirection for signed-in users, you can use the `useUser` hook to check the user's sign-in status and perform the redirection if necessary. - +Renders a sign-up page component. Can be displayed as a full page or embedded within other content. -![Sign Up Component](../imgs/sign-up.png) +## Parameters -## Props -- `fullPage` (boolean): Determines whether the component should occupy the full page. Default is `false`. \ No newline at end of file +- `fullPage` (optional): `boolean` - Determines if the sign-up page should be rendered as a full page. Defaults to `false`. + +## Example + +```tsx +import { SignUp } from '@stackframe/stack'; + +// Embedded sign-up form +const EmbeddedSignUp = () => ; + +// Full-page sign-up form +const FullPageSignUp = () => ; +``` \ No newline at end of file diff --git a/docs/fern/docs/pages/sdk/stack-handler.mdx b/docs/fern/docs/pages/sdk/stack-handler.mdx index 639b3af1a0..ce3c2eb4e2 100644 --- a/docs/fern/docs/pages/sdk/stack-handler.mdx +++ b/docs/fern/docs/pages/sdk/stack-handler.mdx @@ -1,16 +1,31 @@ --- -slug: sdk/stack-handler +title: StackHandler --- -The `StackHandler` component is designed to manage navigation for all pages under the `/handler/*` route. It serves as a wrapper component that determines which page to display based on the URL path and configurations in the `StackApp`. +# StackHandler - - By default, this component will redirect users to appropriate pages. For example, if a user is not signed in and tries to access the account settings page, it will redirect the user to the sign-in page. - +Handles routing for various authentication and user management pages in a Stack application. -## Props +## Parameters -- `app` (StackServerApp): The component relies on the configurations from `app` to determine the correct page URLs and handle redirections. -- `params` (object): This should be passed down from the parent component to relay any URL parameters. -- `searchParams` (object): This should be passed down from the parent component to relay any search parameters from the URL. -- `fullPage` (boolean): Determines whether the component should occupy the full page. The default value is `false`. \ No newline at end of file +- `app`: `StackServerApp` - The Stack server application instance. +- `params` (optional): `{ stack?: string[] }` - URL parameters, where `stack` is an array of path segments. +- `searchParams` (optional): `Record` - Query parameters as key-value pairs. +- `fullPage` (optional): `boolean` - Whether to render the component as a full page. + +## Example + +```tsx +import { StackHandler } from '@stackframe/stack'; + +const App = ({ app }) => { + return ( + + ); +}; +``` \ No newline at end of file diff --git a/docs/fern/docs/pages/sdk/stack-provider.mdx b/docs/fern/docs/pages/sdk/stack-provider.mdx new file mode 100644 index 0000000000..cccf0a8511 --- /dev/null +++ b/docs/fern/docs/pages/sdk/stack-provider.mdx @@ -0,0 +1,27 @@ +--- +title: StackProvider +--- + +# StackProvider + +A React component that provides the Stack context to its children. It sets up the necessary environment for Stack functionality. + +## Parameters + +- `children`: `React.ReactNode` - The child components to be wrapped by the StackProvider. +- `app`: `StackClientApp` - The Stack client app instance. + +## Example + +```tsx +import { StackProvider } from '@stackframe/stack'; +import { app } from './stackApp'; + +function App() { + return ( + + + + ); +} +``` \ No newline at end of file diff --git a/docs/fern/docs/pages/sdk/stack-theme.mdx b/docs/fern/docs/pages/sdk/stack-theme.mdx new file mode 100644 index 0000000000..89d1ee87fd --- /dev/null +++ b/docs/fern/docs/pages/sdk/stack-theme.mdx @@ -0,0 +1,32 @@ +--- +title: StackTheme +--- + +# StackTheme + +A component to apply a custom theme to your Stack application. It wraps your app and provides theme context. + +## Parameters + +- `theme` (optional): `ThemeConfig` - Custom theme configuration to override default values. +- `children` (optional): `React.ReactNode` - Child components to be wrapped by the theme provider. +- `nonce` (optional): `string` - A nonce for the inline script and style tags for added security. + +## Example + +```tsx +import { StackTheme } from '@stackframe/stack'; + +function App() { + const customTheme = { + light: { backgroundColor: '#f0f0f0' }, + dark: { backgroundColor: '#1a1a1a' } + }; + + return ( + + + + ); +} +``` \ No newline at end of file diff --git a/docs/fern/docs/pages/sdk/use-stack-app.mdx b/docs/fern/docs/pages/sdk/use-stack-app.mdx index 19c9965186..7919820caa 100644 --- a/docs/fern/docs/pages/sdk/use-stack-app.mdx +++ b/docs/fern/docs/pages/sdk/use-stack-app.mdx @@ -1,16 +1,27 @@ --- -slug: sdk/use-stack-app +title: useStackApp --- -The `useStackApp` hook returns the `StackClientApp` object that you can use to interact with the Stack API. If you want to learn more about the `StackClientApp` object, check out the [App](./stack-app.mdx) documentation. +# useStackApp -Example: +A React hook that returns the StackClientApp instance within a StackProvider context. -```jsx -import { useStackApp } from "@stackframe/stack"; +## Parameters -function MyComponent() { - const stackApp = useStackApp(); - return
Sign In URL: {stackApp.urls.signIn}
; -} +- `options` (optional): An object with the following property: + - `projectIdMustMatch` (optional): `ProjectId` - A string type parameter to enforce a specific project ID. + +## Example + +```tsx +import { useStackApp } from '@stackframe/stack'; + +// Basic usage +const app = useStackApp(); + +// With project ID enforcement +const app = useStackApp<'my-project-id'>({ projectIdMustMatch: 'my-project-id' }); + +// Use the app +const result = app.someMethod(); ``` \ No newline at end of file diff --git a/docs/fern/docs/pages/sdk/use-user.mdx b/docs/fern/docs/pages/sdk/use-user.mdx index f64d84cd3b..8fdadb1ee0 100644 --- a/docs/fern/docs/pages/sdk/use-user.mdx +++ b/docs/fern/docs/pages/sdk/use-user.mdx @@ -1,34 +1,37 @@ --- -slug: sdk/use-user +title: useUser --- -`useUser` is a hook that returns the user object if the user is authenticated; otherwise, it returns `null` by default. However, if you pass in `{ or: "redirect" }` or `{ or: "throw" }` as an option, it will redirect to the login page or throw an error respectively when the user is not authenticated. +# useUser -If you want to learn more about the `User` object, check out the [User](./current-user.mdx) documentation. +A hook to retrieve the current user information with various options for handling authentication and project matching. -## Default Usage +## Parameters -Check if the user is authenticated and display the user's name. -```jsx -import { useUser } from "@stackframe/stack"; +- `options` (optional): `GetUserOptions` - Options for retrieving user information. + - `or` (optional): `'redirect' | 'throw'` - Specifies behavior if user is not authenticated. + - `projectIdMustMatch` (optional): `'internal'` - Ensures the user belongs to an internal project. -function MyComponent() { - const user = useUser(); // user can be null - if (!user) { - return
Not authenticated
; - } - return
Hello, {user.name}
; -} -``` +## Example -## Redirect when not authenticated -By passing `{ or: "redirect" }` to the hook, it will redirect to the login page if the user is not authenticated. You can configure the login page in the StackApp component. -```jsx -import { useUser } from "@stackframe/stack"; +```tsx +import { useUser } from '@stackframe/stack'; -function MyComponent() { - const user = useUser({ or: "redirect" }); // user is garanteed to be non-null - return
Hello, {user.name}
; +// Basic usage +const user = useUser(); + +// With options +const internalUser = useUser({ projectIdMustMatch: 'internal' }); + +// With authentication handling +const authenticatedUser = useUser({ or: 'redirect' }); + +// Combined options +const authenticatedInternalUser = useUser({ + or: 'throw', + projectIdMustMatch: 'internal' +}); +``` return
Hello, {user.name}
; } ``` diff --git a/docs/fern/docs/pages/sdk/user-button.mdx b/docs/fern/docs/pages/sdk/user-button.mdx new file mode 100644 index 0000000000..440d94a6a3 --- /dev/null +++ b/docs/fern/docs/pages/sdk/user-button.mdx @@ -0,0 +1,26 @@ +--- +title: UserButton +--- + +# UserButton + +Renders a user button component with a loading state. + +## Parameters + +- `props`: `UserButtonProps` - Properties for configuring the UserButton component. + +## Example + +```tsx +import { UserButton } from '@stackframe/stack'; + +function MyComponent() { + return ; +} + +// With custom properties +function CustomizedUserButton() { + return ; +} +``` \ No newline at end of file