Skip to main content

Installing Threaded Comments

Add Reddit-style threaded comments to your project with a single command.

Prerequisites

1

Initialize CLI

Creates your sublay.json configuration file.
2

Install the Sublay SDK

React (Web):
React Native:
Expo:
The component’s other packages are listed under Required Dependencies. add offers to install any that are missing.
See the CLI Setup Guide for details.

Installation Command

--ref v8 reads the component from the v8 branch of the registry, where the v8 components live.

What Gets Installed

The CLI will:
  1. Fetch the component from the registry based on your sublay.json platform and style settings
  2. Copy the component’s files (42 on React, 43 with Tailwind, 47 on React Native and Expo) into your project at {componentsPath}/comments-threaded/: the component’s own files, and the shared pieces it is built from in shared/. Every file is yours to edit, the shared pieces included.
  3. Transform imports to work with your project structure
  4. Create index.ts barrel export for clean imports
  5. Display usage examples and required dependencies

File Structure Created


Using the Component

After installation, import and use the component:
The section has no scrolling of its own: it is as tall as its comments, and the page scrolls.
The section is bound to a Sublay entity by entityId (or pass the entity object). For a record in your own database, pass its ID as foreignId with createIfNotFound instead; see Attach comments to records you already have.
Make sure your app is wrapped with <SublayProvider>. See the Quick Start Guide for setup details.
On React Native and Expo, the sheets (the comment menu, Report, Sort) also need your whole app wrapped in <GestureHandlerRootView style={{ flex: 1 }}> from react-native-gesture-handler. Without it they don’t open or drag. react-native-reanimated needs its Babel setup too: Expo’s preset does it for you; on React Native, follow Reanimated’s install steps.
The Tailwind variant on React Native and Expo needs NativeWind set up in your app, or the components render unstyled. See Tailwind on React Native and Expo.

Switching Styling Variants

To switch between Tailwind and Inline Styles after installation:
1

Delete Current Components

2

Update Configuration

Edit sublay.json:
3

Re-install

This replaces your component files. Back up any customizations first.

Troubleshooting

Make sure your import path matches your paths.components in sublay.json:
ThreadedCommentSection and ThreadedCommentInput share state that ThreadedComments holds, so they throw ThreadedCommentSection must be rendered inside <ThreadedComments>. (or the same for ThreadedCommentInput) when they are rendered outside it. Wrap the screen that renders them in <ThreadedComments>.
Ensure your tsconfig.json includes the components directory:
Re-running add overwrites the existing installation. The CLI prints a warning first, then proceeds:
Because these files are yours to edit, any customizations you made are replaced. Commit (or back up) your changes before re-adding a component:

Next Steps

Props & API

Learn about available props

File Structure

Understand the component organization

Customization

Customize colors, layout, and functionality

Features

Explore all features