Skip to main content

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 created

Step 1: Initialize the CLI

Run the init command in your project directory:

Answer the prompts:

1

Select Platform

2

Choose Styling

  • Select Tailwind CSS if you use Tailwind
  • Select Inline Styles otherwise
3

Set Component Path

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)

The CLI will prompt you to install these automatically if they’re missing.

Step 3: Add a Component

Reddit-style discussions with unlimited nesting, upvote/downvote, threading lines, and collapsible threads.
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:
To post, reply or vote, a user must be signed in. Sublay’s built-in auth handles sign-up and sign-in for you; the complete example below adds a sign-in form.
If your app already has its own authentication, see External Authentication to connect it to Sublay.

Step 5: Use the Component

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. 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).

What Gets Installed

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

Troubleshooting

Make sure the import path matches your paths.components in sublay.json:
  1. Check that <SublayProvider> wraps the component
  2. Verify projectId is correctly set
  3. Check the browser console for errors
Ensure your tsconfig.json includes the components directory:
Set darkMode: 'class' in tailwind.config.js and add a dark class to a parent element:

Next Steps

Props API

Learn about available props and options

File Structure

Understand the installed file organization

Customization

Customize colors, layout, and functionality

Styling Variants

Inline styles vs Tailwind CSS