Command Line Interface
The following is a comprehensive reference of the Redwood CLI. You can get a glimpse of all the commands by scrolling the aside to the right.
The Redwood CLI has two entry-point commands:
- redwood (alias
rw
), which is for developing an application, and - redwood-tools (alias
rwt
), which is for contributing to the framework.
This document covers the redwood
command . For redwood-tools
, see Contributing in the Redwood repo.
A Quick Note on Syntax
We use yargs and borrow its syntax here:
yarn redwood generate page <name> [path] --option
redwood g page
is the command.<name>
and[path]
are positional arguments.<>
denotes a required argument.[]
denotes an optional argument.
--option
is an option.
Every argument and option has a type. Here <name>
and [path]
are strings and --option
is a boolean.
You'll also sometimes see arguments with trailing ..
like:
yarn redwood build [side..]
The ..
operator indicates that the argument accepts an array of values. See Variadic Positional Arguments.
create redwood-app
Create a Redwood project using the yarn create command:
yarn create redwood-app <project directory> [option]
Arguments & Options | Description |
---|---|
project directory | Specify the project directory [Required] |
--yarn-install | Enables the yarn install step and version-requirement checks. You can pass --no-yarn-install to disable this behavior |
--typescript , --ts | Generate a TypeScript project. JavaScript by default |
--overwrite | Create the project even if the specified project directory isn't empty |
--no-telemetry | Disable sending telemetry events for this create command and all Redwood CLI commands: https://telemetry.redwoodjs.com |
--yarn1 | Use yarn 1 instead of yarn 3 |
--git-init , --git | Initialize a git repo during the install process, disabled by default |
If you run into trouble during the yarn install step, which may happen if you're developing on an external drive and in other miscellaneous scenarios, try the --yarn1
flag:
yarn create redwood-app my-redwood-project --yarn1
build
Build for production.
yarn redwood build [side..]
We use Babel to transpile the api side into ./api/dist
and Vite to package the web side into ./web/dist
.
Arguments & Options | Description |
---|---|
side | Which side(s) to build. Choices are api and web . Defaults to api and web |
--verbose, -v | Print more information while building |
Usage
See Builds.
Example
Running yarn redwood build
without any arguments generates the Prisma client and builds both sides of your project:
~/redwood-app$ yarn redwood build
yarn run v1.22.4
$ /redwood-app/node_modules/.bin/redwood build
✔ Generating the Prisma client...
✔ Building "api"...
✔ Building "web"...
Done in 17.37s.
Files are output to each side's dist
directory:
├── api
│ ├── dist
│ ├── prisma
│ └── src
└── web
├── dist
├── public
└── src
check (alias diagnostics)
Get structural diagnostics for a Redwood project (experimental).
yarn redwood check
Example
~/redwood-app$ yarn redwood check
yarn run v1.22.4
web/src/Routes.js:14:5: error: You must specify a 'notfound' page
web/src/Routes.js:14:19: error: Duplicate Path
web/src/Routes.js:15:19: error: Duplicate Path
web/src/Routes.js:17:40: error: Page component not found
web/src/Routes.js:17:19: error (INVALID_ROUTE_PATH_SYNTAX): Error: Route path contains duplicate parameter: "/{id}/{id}"
console (alias c)
Launch an interactive Redwood shell (experimental):
- This has not yet been tested on Windows.
- The Prisma Client must be generated prior to running this command, e.g.
yarn redwood prisma generate
. This is a known issue.
yarn redwood console
Right now, you can only use the Redwood console to interact with your database (always with await
):