Quick Start Guide
This guide installs a Sublay component into your project and renders it: a comment section bound to a Sublay entity, or the notifications bell. It focuses on the components. For a whole app built on Sublay — sign-up, creating and listing entities, comments and reactions — start with Build your first Sublay app.Before You Begin
- ✅ Node.js 20.5+ installed
- ✅ A React, React Native, or Expo project
- ✅ A Sublay project with the
entitiesandcommentsbundles installed, plusreactions(votes and likes) andmoderation(the report button files reports through it). See Bundles.
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
sublay.json configuration file and checks for required dependencies.
Step 2: Install Dependencies (if needed)
- React (Web)
- React Native
- Expo
The CLI will prompt you to install these automatically if they’re missing.
Step 3: Add a Component
Pick a component and a language to get the command:- Threaded comments — Reddit-style discussions with unlimited nesting, upvote/downvote, threading lines, and collapsible threads.
- Social comments — Instagram-style comments with single-level nesting, heart/like system, and Top/New/Old sorting.
- Notifications — a notification bell with a dropdown of the user’s notifications.
--ref v8 reads the component from the v8 branch of the registry, where the v8 components live.
The CLI copies about 40 source files into your project and shows a usage example. It also checks your package.json for the third-party packages the component needs (the Giphy packages for the GIF picker, for example) and offers to install the ones that are missing.
Step 4: Set Up SublayProvider
Wrap your app (or the relevant section) withSublayProvider:
- React (Web)
- React Native / Expo
If your app already has its own authentication, see External Authentication to connect it to Sublay.
Step 5: Use the Component
Bind the comment section to a Sublay entity: pass itsentityId, or the entity object itself. Entities are what your users create — with useCreateEntity, for example — and what you load with useEntityList or EntityProvider.
- Threaded Comments
ThreadedComments wraps the screen, ThreadedCommentSection (Sort by and the comments) goes in its ScrollView, and ThreadedCommentInput (the comment box) is pinned below:Complete Example
A working page: a sign-in form, using built-in auth, and a list of the newest entities, each with its own comment section. Users sign up withsignUpWithEmailAndPassword 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).
SocialCommentSection from ./components/comments-social and use it the same way. To let users create the entities in the list, see Build your first Sublay app.
Attach Comments to Records You Already Have
If what users comment on lives in your own database — an article in your CMS, a product in your catalog — you don’t need to create its entity yourself. Pass your record’s ID asforeignId, with createIfNotFound, and the section creates the entity the first time it loads and finds it by that ID afterwards:
- Threaded Comments
ThreadedComments.createIfNotFound creates the record’s entity the first time its comment section loads. That entity has no author, and the project’s Who can create entities without an author setting decides who may create one. The default, Everyone, lets any visitor’s section create it; under Signed-in users only or No one from the client, see createIfNotFound for threaded and social comments.What Gets Installed
shared/, the presentational pieces the component is built from.
Troubleshooting
Import errors after adding component
Import errors after adding component
Make sure the import path matches your
paths.components in sublay.json:Components not rendering
Components not rendering
- Check that
<SublayProvider>wraps the component - Verify
projectIdis correctly set - Check the browser console for errors
TypeScript errors
TypeScript errors
Ensure your
tsconfig.json includes the components directory:Dark mode not working (Tailwind)
Dark mode not working (Tailwind)
React: make Tailwind’s dark mode follow a React Native and Expo: pass
dark class (Tailwind CSS 3: darkMode: 'class' in tailwind.config.js; Tailwind CSS 4: @custom-variant dark (&:where(.dark, .dark *)); in your CSS), and add a dark class to a parent element:theme="dark" to the component. There is no Tailwind dark mode setup.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

