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

# ⚡️ Quickstart

> Using the @basictech/expo library with your React Native project

## Installation

Install the package via npm:

```bash theme={null}
npm install @basictech/expo
```

## Define a schema

Define your database schema as a TypeScript constant (e.g., `src/schema.ts`):

```typescript theme={null}
// src/basic.config.ts
export const schema = {
  project_id: 'YOUR_PROJECT_ID', // Replace with your actual project ID
  version: 1,
  tables: {
    // example table for a notes app
    notes: {
      type: 'collection',
      fields: {
        title: { type: 'string', indexed: true },
        content: { type: 'string' },
        createdAt: { type: 'number', indexed: true },
        completed: { type: 'boolean', indexed: true },
        priority: { type: 'number', indexed: true },
        tags: { type: 'json', indexed: true }
      },
    },
    // Add other tables here
  },
};
```

## Provider Integration

Wrap your application's root with the `BasicProvider`:

```tsx theme={null}
// App.tsx
import { BasicProvider } from '@basictech/expo';
import { schema } from './basic.config';
import MainApp from './MainApp';

export default function App() {
  return (
    <BasicProvider schema={schema}>
      <MainApp />
    </BasicProvider>
  );
}
```

<Note>`project_id` is inferred from `schema.project_id` on `BasicProvider`; passing `project_id` separately is deprecated.</Note>

**Note:** Set the correct URI scheme under `expo.scheme` in `app.json` so OAuth redirects return to your app.

## Authentication & State Management

Use the `useBasic` hook from `@basictech/expo` inside your components to access authentication state and database client:

```tsx theme={null}
import { useBasic } from '@basictech/expo';

const { user, signIn, signOut, db, isLoading, isSignedIn } = useBasic();
```

**Returned properties:**

* `user`: The authenticated user or null.
* `signIn()`: Starts the OAuth login flow.
* `signOut()`: Logs the user out, clearing all tokens.
* `db`: The main [database client](/sdk-reference/expo-rn).
* `isLoading`: True during authentication state checks.
* `isSignedIn`: Whether a user is authenticated.
