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

# Quick Start

> Get comment components running in under 5 minutes

# Quick Start Guide

This guide will have you up and running with Sublay comment components in under 5 minutes.

***

## Before You Begin

* ✅ Node.js 20.5+ installed
* ✅ A React, React Native, or Expo project
* ✅ A [Sublay project](https://dash.sublay.io) created

***

## Step 1: Initialize the CLI

Run the init command in your project directory:

```bash theme={null}
cd your-project
npx @sublay/cli init
```

### Answer the prompts:

**1. Select Platform**

```
? Which platform are you using?
❯ React (Web)
  React Native
  Expo
```

**2. Choose Styling**

```
? Which styling approach do you prefer?
❯ Tailwind CSS
  Inline Styles
```

* Select **Tailwind CSS** if you use Tailwind
* Select **Inline Styles** otherwise

**3. Set Component Path**

```
? Where should components be installed? (src/components)
```

Press Enter to use the default, or type a custom path.

The CLI creates a `sublay.json` configuration file and checks for required dependencies.

***

## Step 2: Install Dependencies (if needed)

> [tab] React (Web)
>
> ```bash theme={null}
> npm install @sublay/react-js
> ```

> [tab] React Native
>
> ```bash theme={null}
> npm install @sublay/react-native
> ```

> [tab] Expo
>
> ```bash theme={null}
> npm install @sublay/expo
> ```

> [!NOTE]
>
> The CLI will prompt you to install these automatically if they're missing.

***

## Step 3: Add a Component

> [tab] Threaded Comments
>
> ```bash theme={null}
> npx @sublay/cli add comments-threaded
> ```
>
> Reddit-style discussions with unlimited nesting, upvote/downvote, threading lines, and collapsible threads.

> [tab] Social Comments
>
> ```bash theme={null}
> npx @sublay/cli add comments-social
> ```
>
> Instagram-style comments with single-level nesting, heart/like system, and Top/New/Old sorting.

The CLI copies \~25 source files into your project and shows a usage example.

***

## Step 4: Set Up SublayProvider

Wrap your app (or the relevant section) with `SublayProvider`:

> [tab] React (Web)
>
> ```tsx theme={null}
> // App.tsx
> import { SublayProvider } from '@sublay/react-js';
>
> function App() {
>   return (
>     <SublayProvider projectId="your-project-id">
>       {/* Your app content */}
>     </SublayProvider>
>   );
> }
> ```

> [tab] React Native / Expo
>
> ```tsx theme={null}
> // App.tsx
> import { SublayProvider } from '@sublay/react-native'; // or '@sublay/expo'
>
> function App() {
>   return (
>     <SublayProvider projectId="your-project-id">
>       {/* Your app content */}
>     </SublayProvider>
>   );
> }
> ```

To post, reply or vote, a user must be signed in. Sublay's [built-in auth](https://docs.sublay.io/v7/sdk/authentication/built-in.md) handles sign-up and sign-in for you; the [complete example](#complete-example) below adds a sign-in form.

> [!NOTE]
>
> If your app already has its own authentication, see [External Authentication](https://docs.sublay.io/v7/sdk/authentication/external.md) to connect it to Sublay.

***

## Step 5: Use the Component

> [tab] Threaded Comments
>
> ```tsx theme={null}
> // BlogPost.tsx
> import { ThreadedCommentSection } from './components/comments-threaded';
>
> function BlogPost({ post }) {
>   return (
>     <div>
>       <h1>{post.title}</h1>
>       <p>{post.content}</p>
>       <ThreadedCommentSection entityId={post.id} />
>     </div>
>   );
> }
> ```

> [tab] Social Comments
>
> ```tsx theme={null}
> // Post.tsx
> import { SocialCommentSection } from './components/comments-social';
>
> function Post({ post }) {
>   return (
>     <div>
>       <img src={post.image} />
>       <p>{post.caption}</p>
>       <SocialCommentSection entityId={post.id} />
>     </div>
>   );
> }
> ```

That's it! You now have a fully functional comment system.

***

## Complete Example

A working page with a sign-in form, using [built-in auth](https://docs.sublay.io/v7/sdk/authentication/built-in.md). Users sign up with `signUpWithEmailAndPassword` the same way. Sublay doesn't require a username, but the comment components do: as installed, they stop a user without one from posting, replying, voting or reporting. Pass a `username` at sign-up, or change `usernameRequiredCallback` in `hooks/use-threaded-comments.tsx` (or `hooks/use-social-comments.tsx`).

> [tab] Threaded Comments
>
> ```tsx theme={null}
> import { SublayProvider, useAuth } from '@sublay/react-js';
> import { ThreadedCommentSection } from './components/comments-threaded';
>
> const PROJECT_ID = import.meta.env.VITE_PUBLIC_SUBLAY_PROJECT_ID;
>
> function SignInForm() {
>   const { initialized, accessToken, signInWithEmailAndPassword } = useAuth();
>
>   // Hide the form until auth has loaded, and once the user is signed in
>   if (!initialized || accessToken) return null;
>
>   const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
>     e.preventDefault();
>     const form = e.currentTarget;
>     signInWithEmailAndPassword({
>       email: form.email.value,
>       password: form.password.value,
>     }).catch(console.error);
>   };
>
>   return (
>     <form onSubmit={handleSubmit}>
>       <input name="email" type="email" placeholder="Email" />
>       <input name="password" type="password" placeholder="Password" />
>       <button type="submit">Sign in</button>
>     </form>
>   );
> }
>
> function App() {
>   return (
>     <SublayProvider projectId={PROJECT_ID}>
>       <div className="max-w-4xl mx-auto p-8">
>         <SignInForm />
>         <h1>My Blog Post</h1>
>         <p>This is my awesome blog post content...</p>
>         <ThreadedCommentSection entityId="blog-post-123" />
>       </div>
>     </SublayProvider>
>   );
> }
>
> export default App;
> ```

> [tab] Social Comments
>
> ```tsx theme={null}
> import { SublayProvider, useAuth } from '@sublay/react-js';
> import { SocialCommentSection } from './components/comments-social';
>
> const PROJECT_ID = import.meta.env.VITE_PUBLIC_SUBLAY_PROJECT_ID;
>
> function SignInForm() {
>   const { initialized, accessToken, signInWithEmailAndPassword } = useAuth();
>
>   // Hide the form until auth has loaded, and once the user is signed in
>   if (!initialized || accessToken) return null;
>
>   const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
>     e.preventDefault();
>     const form = e.currentTarget;
>     signInWithEmailAndPassword({
>       email: form.email.value,
>       password: form.password.value,
>     }).catch(console.error);
>   };
>
>   return (
>     <form onSubmit={handleSubmit}>
>       <input name="email" type="email" placeholder="Email" />
>       <input name="password" type="password" placeholder="Password" />
>       <button type="submit">Sign in</button>
>     </form>
>   );
> }
>
> function App() {
>   return (
>     <SublayProvider projectId={PROJECT_ID}>
>       <div className="max-w-4xl mx-auto p-8">
>         <SignInForm />
>         <h1>My Post</h1>
>         <p>Check out this amazing photo!</p>
>         <SocialCommentSection entityId="post-456" />
>       </div>
>     </SublayProvider>
>   );
> }
>
> export default App;
> ```

***

## What Gets Installed

```
src/components/comments-threaded/
├── index.ts
├── components/          # ~20 UI component files
│   ├── threaded-comment-section.tsx
│   ├── new-comment-form.tsx
│   ├── comments-feed/
│   └── modals/
├── hooks/
├── utils/
└── context/
```

All files are editable TypeScript/TSX, documented with inline comments, and committed to your repo.

***

## Troubleshooting

> [accordion] Import errors after adding component
>
> Make sure the import path matches your `paths.components` in `sublay.json`:
>
> ```tsx theme={null}
> // paths.components = "src/components"
> import { ThreadedCommentSection } from './components/comments-threaded';
>
> // paths.components = "app/ui"
> import { ThreadedCommentSection } from './ui/comments-threaded';
> ```

> [accordion] Components not rendering
>
> 1. Check that `<SublayProvider>` wraps the component
> 2. Verify `projectId` is correctly set
> 3. Check the browser console for errors

> [accordion] TypeScript errors
>
> Ensure your `tsconfig.json` includes the components directory:
>
> ```json theme={null}
> { "include": ["src/**/*"] }
> ```

> [accordion] Dark mode not working (Tailwind)
>
> Set `darkMode: 'class'` in `tailwind.config.js` and add a `dark` class to a parent element:
>
> ```tsx theme={null}
> <html className={isDark ? 'dark' : ''}>
> ```

***

## Next Steps

> [card] [Props API](https://docs.sublay.io/v7/components/components/threaded/props-api.md)
>
> Learn about available props and options

> [card] [File Structure](https://docs.sublay.io/v7/components/components/threaded/file-structure.md)
>
> Understand the installed file organization

> [card] [Customization](https://docs.sublay.io/v7/components/customization/overview.md)
>
> Customize colors, layout, and functionality

> [card] [Styling Variants](https://docs.sublay.io/v7/components/customization/styling-variants.md)
>
> Inline styles vs Tailwind CSS


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.