> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shipmobilefast.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Ship Mobile Fast comes with pre-built authentication flows using Expo's SecureStore and your choice of authentication providers.

<Frame>
  <img src="https://mintcdn.com/shipmobilefast-51a499dc/rNBXOQ08cKXtmr3A/images/header/authentication.png?fit=max&auto=format&n=rNBXOQ08cKXtmr3A&q=85&s=3f8fc63324aa634c4843a1f933d1eeac" alt="Auth" className="w-full h-full rounded-xl" width="700" height="320" data-path="images/header/authentication.png" />
</Frame>

## Features

<CardGroup cols={2}>
  <Card title="Email/Password" icon="envelope" href="#how-to-use">
    Users can sign in with their email and password.
  </Card>

  <Card title="Social OAuth" icon="apple" href="/auth/oauth">
    We have Google and Apple OAuth support.
  </Card>

  <Card title="Magic Link" icon="sparkles" href="#how-to-use">
    Sending a magic link to the user's email address
  </Card>

  <Card title="Forgot Password" icon="lock" href="/auth/forgot-password">
    If your users forget their password, they can reset it.
  </Card>

  <Card title="Verify Email" icon="envelope" href="/auth/email-verification">
    Users can verify their email address in the app.
  </Card>
</CardGroup>

## How to use?

<Tabs>
  <Tab title="Supabase">
    <Check>
      Currently implemented and fully supported.
    </Check>

    ```js {1} theme={null}
    import { useAuth } from '@/context/SupabaseProvider';

    const {
      user,
      session,
      initialized,
      signOut,
      signIn,
      signUp,
      sendMagicLink,
      signInWithGoogle,
      signInWithApple,
      createSessionFromUrl,
      handleShowPassword,
      isLoading,
      error,
      isAuthenticated,
      showPassword,
      handleError,
      sendNewPasswordLink,
      setNewPassword,
    } = useAuth();
    ```

    ## Auth Functions

    <AccordionGroup>
      <Accordion title="Sign In With Email/Password" icon="envelope">
        To sign in with email/password, use the `signIn` function.

        ```js theme={null}
        signIn('email@example.com', 'password');
        ```
      </Accordion>

      <Accordion title="Sign Up With Email/Password" icon="user-plus">
        To sign up with email/password, use the `signUp` function.

        ```js theme={null}
        signUp('email@example.com', 'password');
        ```
      </Accordion>

      <Accordion title="Sign In With Google" icon="google">
        To sign in with Google, use the `signInWithGoogle` function.

        ```js theme={null}
        signInWithGoogle();
        ```
      </Accordion>

      <Accordion title="Sign In With Apple" icon="apple">
        To sign in with Apple, use the `signInWithApple` function.

        ```js theme={null}
        signInWithApple();
        ```
      </Accordion>

      <Accordion title="Create Session From URL" icon="sparkles">
        To create a session from a URL, use the `createSessionFromUrl` function.

        <Info>
          Magic happens here. Don't change this.
        </Info>
      </Accordion>

      <Accordion title="Handle Show Password" icon="lock">
        To handle show password on the password input, use the `handleShowPassword` function.

        ```js theme={null}
        handleShowPassword();
        ```
      </Accordion>

      <Accordion title="Error Handling" icon="triangle-exclamation">
        To handle errors, use the `handleError` function.

        ```js theme={null}
        handleError(error);
        ```
      </Accordion>

      <Accordion title="Send New Password Link" icon="envelope">
        To send a new password link, use the `sendNewPasswordLink` function.

        ```js theme={null}
        sendNewPasswordLink('email@example.com');
        ```
      </Accordion>

      <Accordion title="Set New Password" icon="lock">
        To set a new password, use the `setNewPassword` function.

        ```js theme={null}
        setNewPassword('newPassword');
        ```
      </Accordion>

      <Accordion title="Sign Out" icon="right-from-bracket">
        To sign out, use the `signOut` function.

        ```js theme={null}
        signOut();
        ```
      </Accordion>

      <Accordion title="Send Magic Link" icon="sparkles">
        To send a magic link, use the `sendMagicLink` function.

        ```js theme={null}
        sendMagicLink('email@example.com');
        ```
      </Accordion>
    </AccordionGroup>

    ### Props

    | Value                  | Type                                                 | Description                                     |                             |
    | ---------------------- | ---------------------------------------------------- | ----------------------------------------------- | --------------------------- |
    | `user`                 | `UserMetaData \| null`                               | Contains current authenticated user information |                             |
    | `session`              | `Session \| null`                                    | Contains active session information             |                             |
    | `initialized`          | `boolean`                                            | Indicates if auth state has been initialized    |                             |
    | `signOut`              | `() => Promise<void>`                                | Signs out the current user                      |                             |
    | `signIn`               | `(email: string, password: string) => Promise<void>` | Signs in user with email/password               |                             |
    | `signUp`               | `(email: string, password: string) => Promise<void>` | Creates a new user account                      |                             |
    | `sendMagicLink`        | `(email: string) => Promise<void>`                   | Sends a magic link to user's email              |                             |
    | `signInWithGoogle`     | `() => Promise<void>`                                | Initiates Google OAuth sign in                  |                             |
    | `signInWithApple`      | `() => Promise<void>`                                | Initiates Apple OAuth sign in                   |                             |
    | `createSessionFromUrl` | `(url: string) => Promise<void>`                     | Creates session from URL                        |                             |
    | `handleShowPassword`   | `() => void`                                         | Toggles password visibility                     |                             |
    | `isLoading`            | `boolean`                                            | Indicates if auth operation is in progress      |                             |
    | `error`                | `Error \| null`                                      | Contains error information if any               |                             |
    | `isAuthenticated`      | `boolean`                                            | Indicates if user is authenticated              |                             |
    | `showPassword`         | `boolean`                                            | Controls password visibility state              |                             |
    | `handleError`          | \`(error:  AuthError                                 | Error) => void\`                                | Handles auth-related errors |
    | `sendNewPasswordLink`  | `(email: string) => Promise<void>`                   | Sends password reset link                       |                             |
    | `setNewPassword`       | `(password: string) => Promise<void>`                | Sets new password                               |                             |
  </Tab>

  <Tab title="Firebase">
    <Warning>
      Coming soon.
    </Warning>
  </Tab>
</Tabs>
