or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

addon-management.mdautomigration.mdcode-migration.mdcore-commands.mddevelopment-tools.mddiagnostics.mdindex.mdinitialization.mdversion-management.md

core-commands.mddocs/

0

# Core Commands

1

2

Essential daily-use commands for developing and building Storybook projects. These commands from the core `storybook` package provide the fundamental development workflow operations.

3

4

## Capabilities

5

6

### Development Server

7

8

Start Storybook development server with hot reloading and interactive features.

9

10

```bash { .api }

11

storybook dev [options]

12

13

Options:

14

-p, --port <number> Port to run Storybook (default: auto-detected)

15

-h, --host <string> Host to run Storybook

16

-c, --config-dir <dir-name> Directory where to load Storybook configurations from

17

--https Serve Storybook over HTTPS

18

--ssl-ca <ca> Provide SSL certificate authority (array)

19

--ssl-cert <cert> Provide SSL certificate (required with --https)

20

--ssl-key <key> Provide SSL key (required with --https)

21

--smoke-test Exit after successful start

22

--ci CI mode (skip interactive prompts, don't open browser)

23

--no-open Do not open Storybook automatically in the browser

24

--quiet Suppress verbose build output

25

--no-version-updates Suppress update check

26

--debug-webpack Display final webpack configurations for debugging

27

--webpack-stats-json [directory] Write Webpack stats JSON to disk

28

--stats-json [directory] Write stats JSON to disk

29

--preview-url <string> Disables default storybook preview, use your own

30

--force-build-preview Build preview iframe even with --preview-url

31

--docs Build a documentation-only site using addon-docs

32

--exact-port Exit early if desired port is not available

33

--initial-path [path] URL path to append when visiting Storybook initially

34

--preview-only Use the preview without the manager UI

35

```

36

37

**Usage Examples:**

38

39

```bash

40

# Start development server on default port

41

storybook dev

42

43

# Start on specific port and host

44

storybook dev --port 8080 --host 0.0.0.0

45

46

# Start with HTTPS

47

storybook dev --https --ssl-cert ./cert.pem --ssl-key ./key.pem

48

49

# Start in CI mode (no browser, non-interactive)

50

storybook dev --ci --smoke-test

51

52

# Start with docs-only mode

53

storybook dev --docs

54

55

# Start with custom config directory

56

storybook dev --config-dir ./custom-storybook

57

58

# Debug webpack configuration

59

storybook dev --debug-webpack --webpack-stats-json

60

```

61

62

### Production Build

63

64

Build Storybook for production deployment as static files.

65

66

```bash { .api }

67

storybook build [options]

68

69

Options:

70

-o, --output-dir <dir-name> Directory where to store built files

71

-c, --config-dir <dir-name> Directory where to load Storybook configurations from

72

--quiet Suppress verbose build output

73

--debug-webpack Display final webpack configurations for debugging

74

--webpack-stats-json [directory] Write Webpack stats JSON to disk

75

--stats-json [directory] Write stats JSON to disk

76

--preview-url <string> Disables default storybook preview, use your own

77

--force-build-preview Build preview iframe even with --preview-url

78

--docs Build a documentation-only site using addon-docs

79

--test Build stories optimized for testing purposes

80

--preview-only Use the preview without the manager UI

81

```

82

83

**Usage Examples:**

84

85

```bash

86

# Build to default output directory (storybook-static)

87

storybook build

88

89

# Build to custom output directory

90

storybook build --output-dir ./dist/storybook

91

92

# Build docs-only site

93

storybook build --docs

94

95

# Build for testing (optimized for test runners)

96

storybook build --test

97

98

# Build with custom config directory

99

storybook build --config-dir ./custom-storybook

100

101

# Build with webpack stats for analysis

102

storybook build --webpack-stats-json ./webpack-stats

103

104

# Quiet build (minimal output)

105

storybook build --quiet

106

```

107

108

### Index Generation

109

110

Generate story index for external tools and integrations.

111

112

```bash { .api }

113

storybook index [options]

114

115

Options:

116

-o, --output-file <file-name> JSON file to output index

117

-c, --config-dir <dir-name> Directory where to load Storybook configurations from

118

--quiet Suppress verbose build output

119

```

120

121

**Usage Examples:**

122

123

```bash

124

# Generate index to default file

125

storybook index

126

127

# Generate index to custom file

128

storybook index --output-file ./stories-index.json

129

130

# Generate index with custom config directory

131

storybook index --config-dir ./custom-storybook --output-file ./index.json

132

```

133

134

### Programmatic Usage

135

136

For programmatic usage, import functions from the core server package:

137

138

```typescript { .api }

139

import {

140

buildDevStandalone,

141

buildStaticStandalone,

142

buildIndex,

143

buildIndexStandalone

144

} from "storybook/internal/core-server";

145

146

/**

147

* Start development server programmatically

148

* @param options - Development server configuration options

149

* @returns Promise with server connection details

150

*/

151

function buildDevStandalone(

152

options: CLIOptions & LoadOptions & BuilderOptions & {

153

storybookVersion?: string;

154

previewConfigPath?: string;

155

}

156

): Promise<{ port: number; address: string; networkAddress: string }>;

157

158

/**

159

* Build Storybook for production programmatically

160

* @param options - Build configuration options

161

* @returns Promise that resolves when build is complete

162

*/

163

function buildStaticStandalone(options: BuildStaticStandaloneOptions): Promise<void>;

164

165

/**

166

* Generate story index programmatically

167

* @param options - Index generation options

168

* @returns Promise with the generated story index

169

*/

170

function buildIndex(options: BuildIndexOptions): Promise<StoryIndex>;

171

172

/**

173

* Generate and write story index to file programmatically

174

* @param options - Index generation and output options

175

* @returns Promise that resolves when index is written

176

*/

177

function buildIndexStandalone(

178

options: BuildIndexOptions & { outputFile: string }

179

): Promise<void>;

180

```

181

182

**Usage Examples:**

183

184

```typescript

185

import {

186

buildDevStandalone,

187

buildStaticStandalone,

188

buildIndex,

189

buildIndexStandalone

190

} from "storybook/internal/core-server";

191

192

// Start development server

193

const result = await buildDevStandalone({

194

configDir: './.storybook',

195

port: 6006,

196

host: 'localhost',

197

packageJson: require('./package.json')

198

});

199

console.log(`Storybook started on port ${result.port}`);

200

201

// Build for production

202

await buildStaticStandalone({

203

configDir: './.storybook',

204

outputDir: './storybook-static',

205

quiet: false,

206

packageJson: require('./package.json')

207

});

208

209

// Generate story index

210

const index = await buildIndex({

211

configDir: './.storybook',

212

packageJson: require('./package.json')

213

});

214

215

// Generate and write story index to file

216

await buildIndexStandalone({

217

configDir: './.storybook',

218

outputFile: './stories.json',

219

packageJson: require('./package.json')

220

});

221

```

222

223

## Types

224

225

```typescript { .api }

226

interface CLIOptions extends CLIBaseOptions {

227

port?: number;

228

ignorePreview?: boolean;

229

previewUrl?: string;

230

forceBuildPreview?: boolean;

231

host?: string;

232

initialPath?: string;

233

exactPort?: boolean;

234

https?: boolean;

235

sslCa?: string[];

236

sslCert?: string;

237

sslKey?: string;

238

smokeTest?: boolean;

239

managerCache?: boolean;

240

open?: boolean;

241

ci?: boolean;

242

versionUpdates?: boolean;

243

docs?: boolean;

244

test?: boolean;

245

debugWebpack?: boolean;

246

webpackStatsJson?: string | boolean;

247

statsJson?: string | boolean;

248

outputDir?: string;

249

previewOnly?: boolean;

250

}

251

252

interface CLIBaseOptions {

253

disableTelemetry?: boolean;

254

enableCrashReports?: boolean;

255

configDir?: string;

256

loglevel?: string;

257

quiet?: boolean;

258

}

259

260

interface LoadOptions {

261

packageJson?: PackageJson;

262

outputDir?: string;

263

configDir?: string;

264

cacheKey?: string;

265

ignorePreview?: boolean;

266

extendServer?: (server: HttpServer) => void;

267

}

268

269

interface BuilderOptions {

270

configType?: "DEVELOPMENT" | "PRODUCTION";

271

ignorePreview?: boolean;

272

cache?: FileSystemCache;

273

configDir: string;

274

docsMode?: boolean;

275

features?: StorybookConfigRaw["features"];

276

versionCheck?: VersionCheck;

277

disableWebpackDefaults?: boolean;

278

serverChannelUrl?: string;

279

}

280

281

type BuildStaticStandaloneOptions = CLIOptions & LoadOptions & BuilderOptions & {

282

outputDir: string;

283

};

284

285

type BuildIndexOptions = CLIOptions & LoadOptions & BuilderOptions;

286

287

interface CLIIndexOptions extends CLIBaseOptions {

288

configDir?: string;

289

outputFile?: string;

290

}

291

292

interface StoryIndex {

293

v: number;

294

entries: Record<string, StoryIndexEntry>;

295

}

296

297

interface StoryIndexEntry {

298

id: string;

299

title: string;

300

name: string;

301

importPath: string;

302

type: "docs" | "story";

303

tags?: string[];

304

}

305

```

306

307

## Environment Variables

308

309

All commands support environment variable configuration:

310

311

```bash

312

# Port configuration

313

SBCONFIG_PORT=8080 storybook dev

314

315

# Host configuration

316

SBCONFIG_HOSTNAME=0.0.0.0 storybook dev

317

318

# Config directory

319

SBCONFIG_CONFIG_DIR=./custom-storybook storybook dev

320

321

# Output directory

322

SBCONFIG_OUTPUT_DIR=./dist storybook build

323

324

# CI mode

325

CI=true storybook dev

326

327

# Output file for index

328

SBCONFIG_OUTPUT_FILE=./stories.json storybook index

329

```