Add optional template selection to create-react-router
#13942
Replies: 2 comments 1 reply
-
🤔 I'm not sure about listing all templates again. Last time people started to want to add more and more "official" templates for every single variant of Styling + DB + Auth + whatever. But I like the idea to use the CLI for not only framework mode. Maybe there could be a npm create react-router --mode=declarative
npm create react-router --mode=data
npm create react-router --mode=framework If the I also like the idea of renaming official templates to mention the mode first like |
Beta Was this translation helpful? Give feedback.
-
👍 I am definitely in favor of enhancing the CLI with some auto-filled template options but I also want to avoid it becoming noisy - since that's sort of exactly what we moved away from when we simplified it from the original v1 CLI. I don't like when I run a CLI and then have to answer a bunch of questions. And if I need to use a CLI option to bypass that it should be short/easy/memorable so I don't have to go look it up each time. Here's a brain dump of what I think I'd vote for in an ideal CLI:
npx create-react-router --template remix-run/react-router-templates/javascript
npx create-react-router --template javascript If we did (2) it would would allow us to create framework/data/declarative templates and folks could use them via the shorthand npx create-react-router --template data
# instead of
npx create-react-router --template remix-run/react-router-templates/data
npx create-react-router
> Please choose a mode:
* Framework
* Data
* Declarative
* See more templates... Then if they choose > Please choose a template:
* cloudflare
* cloudflare-d1
* mode-data <- new
* mode-declarative <- new
* mode-framework <- previously `default`
* deno
* javascript
* minimal
* netlify
* node-custom-server
* node-postgres
* vercel I think this gives us the best of both worlds in that the CLI is really easy to use as a one liner with no prompts - you just have to remember For more advanced community templates (formerly stacks), I think we re-introduce the old |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
The existing
create-react-router
CLI should be expanded to provide more options for template selection. Particularly with upcoming support for RSC Data Mode that can more easily target other bundlers, the different ways that you can use React Router should get more exposure in the CLI.Background
The
create-remix
CLI had been rewritten to greatly simplify the amount of options needed to get started, and to help offload templates to the community. Thecreate-react-router
CLI is a port of Remix v2'screate-remix
CLI. However, this lineage has led to it being less fit for purpose now than when it was originally rewritten.React Router can be used in a variety of ways: Declarative, Data and Framework Modes. In the future we'll also have an RSC-enabled version of Data Mode, followed by unstable support for RSC in Framework Mode. Even in the case of Framework Mode, you can also choose to enable SPA Mode, or use custom entries to target different runtimes.
The current
create-react-router
experience drops you directly into Framework Mode with default options unless you explicitly pass a--template
option. This means that to get a sense of the different options available, you need to navigate this repo out of band, at which point you're simply presented with a list of template names.This also reinforces the idea that Framework Mode is the new default. However, our upcoming work with RSC Data Mode challenges this idea even further since it's becoming feasible to use Data Mode while retaining most of Framework Mode's feature set.
Proposal
Update
create-react-router
to provide the following choice up front.Quick Start
— The current default Framework Mode experience, designed for people who are happy to accept good defaults or who are just experimenting.Choose a Template
— Pulls in the list of templates from https://github.com/remix-run/react-router-templates. As part of this, we could provide additional metadata to improve the CLI experience, e.g. proper titles, descriptions.OPTIONAL: As part of this, we may also want to revisit our templates to ensure they work well in the context of the CLI.
framework-mode-
prefixes etc. to make templates easier to navigate by name and help future proof against anydata-mode-rsc-
templates etc?Browse All Templates
option at the end?Beta Was this translation helpful? Give feedback.
All reactions