Skip to main content

Installing the Sublay CLI

The Sublay CLI copies fully customizable comment components directly into your project as editable source code. Run it with npx: there is nothing to install, and you always get the latest version.

Prerequisites

1

Node.js 20.5+

2

A React, React Native, or Expo project

Supported platforms:
  • React (Web) ✅
  • React Native ✅
  • Expo ✅
3

A Sublay project

Create a project in the Sublay Dashboard if you haven’t already.

Using npx

No installation required — npx always uses the latest version:

Initializing Your Project

Run the init command from your project root:

Interactive Prompts

Question: “Which platform are you using?”Options: React (Web) · React Native · ExpoDetermines which component variants and dependencies are used.
Question: “Which styling approach do you prefer?”Options:
  • Tailwind CSS — Uses utility classes (bg-white dark:bg-gray-800)
  • Inline Styles — Uses style objects (style={{ backgroundColor: '...' }})
Choose Tailwind if your project already uses Tailwind CSS. Otherwise choose Inline Styles.
Question: “Where should components be installed?”Default: src/componentsThe directory where CLI components will be copied. You can use any path.

What Happens During Init

  1. Detects your project type from package.json
  2. Creates sublay.json in your project root

The sublay.json File

After initialization, a sublay.json file is created in your project root:
See Configuration for a full reference.

Adding Components

add reads sublay.json, then:
  1. Downloads the component for your platform and style from the chosen branch.
  2. Downloads the shared pieces the component is built from (the GIF picker, avatar, skeletons, icons and similar) into a shared/ folder inside the component’s own folder.
  3. Writes the files to {paths.components}/<component>/, with imports adjusted to the installed layout. If any file fails to download, nothing is written. Among them is utils/env.ts, written for your framework (Next.js, Vite, Create React App, Expo or React Native; another web framework gets a version for you to fill in): the file the GIF picker reads its Giphy API key from. See GIF Support.
  4. Checks your package.json for the packages the component and its shared pieces need, and offers to install the missing ones.
  5. Prints how to use the component: an import line, or, for a component used as several pieces (threaded comments on React Native and Expo), a short example of how the pieces fit together, with the path the component was installed at.
A branch name may contain letters, digits, ., _, - and /. If the branch or the component does not exist on it, add stops with a message naming the one that is missing and writes nothing. Every installed file is yours to edit, the files in shared/ included. Each component gets its own shared/ folder.

Installing Dependencies

add checks for the packages a component needs and prompts to install them if missing. It installs them with your project’s package manager (npm, yarn, pnpm or bun, from your lock file or the packageManager field of your package.json). On Expo it runs npx expo install, which picks the version of each package that matches your Expo SDK. Without an interactive terminal (a script, CI), it doesn’t prompt: it prints the command to run instead. The Sublay SDK for your platform is always one of the packages: React (Web):
React Native:
Expo:
These packages are required. Components use them for data fetching, authentication, real-time updates, and core functionality.

Troubleshooting

After installing a component’s files, add reads your package.json to check which of the component’s dependencies you already have. If there is no package.json in the current directory it prints this warning and skips that check — the component itself is still installed, and the command still succeeds.Run add from your project root (where package.json lives) to get the dependency check.
  1. Press Ctrl+C to cancel
  2. Clear npx cache: npx clear-npx-cache
  3. Try again: npx @sublay/cli init
Delete sublay.json and run npx @sublay/cli init again, or manually edit the file and re-run add commands.

Next Steps

Quick Start

Add your first component in under 5 minutes

Configuration Reference

Understand every option in sublay.json

Threaded Comments

Add Reddit-style threaded comments

Social Comments

Add Instagram-style social comments