create-tanstack-app 1.1.4 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +133 -61
- package/index.js +8 -53
- package/package.json +1 -1
- package/src/index.ts +0 -0
- package/tsconfig.json +16 -0
package/README.md
CHANGED
|
@@ -1,93 +1,165 @@
|
|
|
1
|
-
# Create TanStack
|
|
1
|
+
# Create React App for TanStack Router
|
|
2
2
|
|
|
3
|
-
This CLI
|
|
3
|
+
This CLI application builds Tanstack Router applications that are the functional equivalent of [Create React App](https://create-react-app.dev/).
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- Full-Document SSR
|
|
7
|
-
- Streaming
|
|
8
|
-
- Server Functions (RPCs)
|
|
9
|
-
- Automatic type-safe routing with TanStack Router
|
|
10
|
-
- Deployment-ready app setup
|
|
5
|
+
To help accelerate the migration away from `create-react-app` we created the `create-tanstack-app` CLI which is a plug-n-play replacement for CRA.
|
|
11
6
|
|
|
12
|
-
##
|
|
7
|
+
## Quick Start
|
|
13
8
|
|
|
14
|
-
|
|
9
|
+
To maintain compatability with `create-react-app` you can build a new application by running:
|
|
15
10
|
|
|
16
|
-
|
|
11
|
+
| Command | Description |
|
|
12
|
+
| --------------------------------------------------------------------------------- | ------------------------------------------------- |
|
|
13
|
+
| `pnpx create-tanstack-app@latest my-app` | Create a new app |
|
|
14
|
+
| `pnpx create-tanstack-app@latest my-app --template file-router` | Create a new file based app |
|
|
15
|
+
| `pnpx create-tanstack-app@latest my-app --template typescript` | Create a new TypeScript app using the Code Router |
|
|
16
|
+
| `pnpx create-tanstack-app@latest my-app --tailwind` | Add Tailwind CSS support |
|
|
17
|
+
| `pnpx create-tanstack-app@latest my-app --framework solid` | Create a Solid app |
|
|
18
|
+
| `pnpx create-tanstack-app@latest my-app --framework solid --template file-router` | Create a Solid app with file-router |
|
|
19
|
+
|
|
20
|
+
If you don't specify a project name, the CLI will walk you through an interactive setup process:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pnpx create-tanstack-app@latest
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
This will start an interactive CLI that guides you through the setup process, allowing you to choose:
|
|
27
|
+
|
|
28
|
+
- Project Name
|
|
29
|
+
- Router Type (File-based or Code-based routing)
|
|
30
|
+
- TypeScript support
|
|
31
|
+
- Tailwind CSS integration
|
|
32
|
+
- Package manager
|
|
33
|
+
- Toolchain
|
|
34
|
+
- Git initialization
|
|
35
|
+
|
|
36
|
+
## Command Line Options
|
|
37
|
+
|
|
38
|
+
You can also use command line flags to specify your preferences directly:
|
|
17
39
|
|
|
18
40
|
```bash
|
|
19
|
-
|
|
41
|
+
pnpx create-tanstack-app@latest my-app --template file-router --tailwind --package-manager pnpm
|
|
20
42
|
```
|
|
21
43
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
44
|
+
Available options:
|
|
45
|
+
|
|
46
|
+
- `--template <type>`: Choose between `file-router`, `typescript`, or `javascript`
|
|
47
|
+
- `--tailwind`: Enable Tailwind CSS
|
|
48
|
+
- `--package-manager`: Specify your preferred package manager (`npm`, `yarn`, `pnpm`, `bun`, or `deno`)
|
|
49
|
+
- `--toolchain`: Specify your toolchain solution for formatting/linting (`biome`, `eslint+prettier`)
|
|
50
|
+
- `--no-git`: Do not initialize a git repository
|
|
51
|
+
- `--add-ons`: Enable add-on selection or specify add-ons to install
|
|
52
|
+
|
|
53
|
+
When using flags, the CLI will display which options were provided and only prompt for the remaining choices.
|
|
54
|
+
|
|
55
|
+
## Features
|
|
56
|
+
|
|
57
|
+
What you'll get is a Vite application that uses TanStack Router. All the files will still be in the same place as in CRA, but you'll get a fully functional Router setup under in `app/main.tsx`.
|
|
25
58
|
|
|
26
|
-
|
|
59
|
+
`create-tanstack-app` is everything you loved about CRA but implemented with modern tools and best practices, on top of the popular TanStack set of libraries. Which includes [@tanstack/react-query](https://tanstack.com/query/latest) and [@tanstack/react-router](https://tanstack.com/router/latest).
|
|
27
60
|
|
|
28
|
-
|
|
29
|
-
- **TanStack Router**: A powerful type-safe routing system for React.
|
|
30
|
-
- **Vinxi**: A bundler and deployment tool.
|
|
31
|
-
- **Vite**: For fast build and development.
|
|
32
|
-
- **React**: Frontend library to build the app.
|
|
33
|
-
- **TypeScript**: For type safety throughout the app.
|
|
61
|
+
## Routing Options
|
|
34
62
|
|
|
35
|
-
###
|
|
63
|
+
### File Based Routing (Recommended)
|
|
36
64
|
|
|
37
|
-
|
|
65
|
+
File Based Routing is the default option when using the interactive CLI. The location of the home page will be `app/routes/index.tsx`. This approach provides a more intuitive and maintainable way to structure your routes.
|
|
38
66
|
|
|
67
|
+
To explicitly choose File Based Routing, use:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pnpx create-tanstack-app@latest my-app --template file-router
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Code Based Routing
|
|
74
|
+
|
|
75
|
+
If you prefer traditional code-based routing, you can select it in the interactive CLI or specify it by using either the `typescript` or `javascript` template:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pnpx create-tanstack-app@latest my-app --template typescript
|
|
39
79
|
```
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
80
|
+
|
|
81
|
+
## Additional Configuration
|
|
82
|
+
|
|
83
|
+
### TypeScript
|
|
84
|
+
|
|
85
|
+
- File Based Routing always uses TypeScript
|
|
86
|
+
- For Code Based Routing, you can choose between TypeScript and JavaScript
|
|
87
|
+
- Enable TypeScript explicitly with `--template typescript`
|
|
88
|
+
|
|
89
|
+
### Tailwind CSS
|
|
90
|
+
|
|
91
|
+
Enable Tailwind CSS either through the interactive CLI or by adding the `--tailwind` flag. This will automatically configure [Tailwind V4](https://tailwindcss.com/).
|
|
92
|
+
|
|
93
|
+
### Package Manager
|
|
94
|
+
|
|
95
|
+
Choose your preferred package manager (`npm`, `bun`, `yarn`, `pnpm`, or `deno`) either through the interactive CLI or using the `--package-manager` flag.
|
|
96
|
+
|
|
97
|
+
Extensive documentation on using the TanStack Router, migrating to a File Base Routing approach, as well as integrating [@tanstack/react-query](https://tanstack.com/query/latest) and [@tanstack/store](https://tanstack.com/store/latest) can be found in the generated `README.md` for your project.
|
|
98
|
+
|
|
99
|
+
### Toolchain
|
|
100
|
+
|
|
101
|
+
Choose your preferred solution for formatting and linting either through the interactive CLI or using the `--toolchain` flag.
|
|
102
|
+
|
|
103
|
+
Setting this flag to `biome` will configure it as your toolchain of choice, adding a `biome.json` to the root of the project. Consult the [biome documentation](https://biomejs.dev/guides/getting-started/) for further customization.
|
|
104
|
+
|
|
105
|
+
Setting this flag to `eslint+prettier` will configure it as your toolchain of choice, adding an `eslint.config.js` and `prettier.config.js` to the root of the project, as well as a `.prettierignore` file. Consult the [eslint documentation](https://eslint.org/docs/latest/) and [prettier documentation](https://prettier.io/docs/) for further customization.
|
|
106
|
+
|
|
107
|
+
## Add-ons (experimental)
|
|
108
|
+
|
|
109
|
+
You can enable add-on selection:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
pnpx create-tanstack-app@latest --add-ons
|
|
52
113
|
```
|
|
53
114
|
|
|
54
|
-
|
|
115
|
+
This will prompt you to select the add-ons you want to enable during application creation.
|
|
55
116
|
|
|
56
|
-
|
|
117
|
+
You can enable specific add-ons directly by adding a comma separated list of add-on names to the `--add-ons` flag. For example:
|
|
57
118
|
|
|
58
119
|
```bash
|
|
59
|
-
|
|
120
|
+
pnpx create-tanstack-app@latest my-app --add-ons shadcn,tanstack-query
|
|
60
121
|
```
|
|
61
122
|
|
|
62
|
-
|
|
123
|
+
You can get a list of all available add-ons by running:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
pnpx create-tanstack-app@latest --list-add-ons
|
|
127
|
+
```
|
|
63
128
|
|
|
64
|
-
|
|
129
|
+
This will display a list of all available add-ons for React that are compatible with the Code Router.
|
|
65
130
|
|
|
66
|
-
|
|
131
|
+
```bash
|
|
132
|
+
pnpx create-tanstack-app@latest --list-add-ons --framework solid --template file-router
|
|
133
|
+
```
|
|
67
134
|
|
|
68
|
-
|
|
135
|
+
Will get you a list of all available add-ons for Solid that are compatible with the File Router.
|
|
69
136
|
|
|
70
|
-
|
|
71
|
-
const { execSync } = require('child_process');
|
|
72
|
-
const fs = require('fs');
|
|
73
|
-
const path = require('path');
|
|
137
|
+
## MCP (Model Context Protocol) Support (experimental)
|
|
74
138
|
|
|
75
|
-
|
|
76
|
-
const targetDir = path.join(process.cwd(), 'tanstack-app');
|
|
139
|
+
You can launch the `create-tanstack-app` CLI with the `--mcp` flag to enable MCP support. Use this in your MCP enabled IDE to allow the Agent model to generate TanStack Router applications.
|
|
77
140
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
execSync(`git clone ${repoUrl} ${targetDir}`, { stdio: 'inherit' });
|
|
141
|
+
```bash
|
|
142
|
+
pnpx create-tanstack-app@latest --mcp
|
|
143
|
+
```
|
|
82
144
|
|
|
83
|
-
|
|
84
|
-
execSync('npm install', { cwd: targetDir, stdio: 'inherit' });
|
|
145
|
+
Here is the JSON configuration for MCP support in many MCP clients.
|
|
85
146
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"mcpServers": {
|
|
150
|
+
"create-tanstack-app": {
|
|
151
|
+
"command": "pnpx",
|
|
152
|
+
"args": ["create-tanstack-app@latest", "--mcp"]
|
|
153
|
+
}
|
|
89
154
|
}
|
|
90
|
-
} catch (error) {
|
|
91
|
-
console.error('Error setting up TanStack app:', error);
|
|
92
155
|
}
|
|
93
|
-
```
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
# Contributing
|
|
159
|
+
|
|
160
|
+
Check out the [Contributing](CONTRIBUTING.md) guide.
|
|
161
|
+
|
|
162
|
+
# License
|
|
163
|
+
|
|
164
|
+
MIT
|
|
165
|
+
|
package/index.js
CHANGED
|
@@ -1,65 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const { execSync } = require("child_process");
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const path = require("path");
|
|
6
|
-
const readline = require("readline");
|
|
7
|
-
|
|
8
|
-
// Prompt the user for input
|
|
9
|
-
const rl = readline.createInterface({
|
|
10
|
-
input: process.stdin,
|
|
11
|
-
output: process.stdout,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
async function getFolderName(defaultName) {
|
|
15
|
-
return new Promise((resolve) => {
|
|
16
|
-
rl.question(
|
|
17
|
-
`Enter the folder name (or use './' for the current directory) [${defaultName}]: `,
|
|
18
|
-
(input) => {
|
|
19
|
-
resolve(input || defaultName);
|
|
20
|
-
}
|
|
21
|
-
);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
4
|
|
|
25
5
|
async function initApp() {
|
|
26
6
|
try {
|
|
27
|
-
// Get
|
|
28
|
-
const
|
|
29
|
-
const folderName = argFolderName || (await getFolderName("my-tanstack-app"));
|
|
30
|
-
rl.close();
|
|
31
|
-
|
|
32
|
-
const dest =
|
|
33
|
-
folderName === "./" ? process.cwd() : path.join(process.cwd(), folderName);
|
|
34
|
-
|
|
35
|
-
// Check if the destination already exists
|
|
36
|
-
if (fs.existsSync(dest)) {
|
|
37
|
-
console.log(
|
|
38
|
-
"❌ Directory already exists. Please choose another name or delete the existing directory."
|
|
39
|
-
);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
console.log("📥 Cloning TanStack app template from GitHub...");
|
|
44
|
-
|
|
45
|
-
// Clone the repository
|
|
46
|
-
execSync(
|
|
47
|
-
`git clone https://github.com/SH20RAJ/tanstack-start.git ${dest}`,
|
|
48
|
-
{
|
|
49
|
-
stdio: "inherit",
|
|
50
|
-
}
|
|
51
|
-
);
|
|
7
|
+
// Get all command-line arguments
|
|
8
|
+
const args = process.argv.slice(2);
|
|
52
9
|
|
|
53
|
-
console.log("
|
|
10
|
+
console.log("📥 Running create-tsrouter-app...");
|
|
54
11
|
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
12
|
+
// Run create-tsrouter-app with forwarded flags
|
|
13
|
+
execSync(`npx create-tsrouter-app ${args.join(" ")}`, {
|
|
14
|
+
stdio: "inherit",
|
|
15
|
+
});
|
|
58
16
|
|
|
59
|
-
console.log(
|
|
60
|
-
console.log(` cd ${folderName === "./" ? "." : folderName}`);
|
|
61
|
-
console.log(` npm run dev`);
|
|
62
|
-
console.log("\n🚀 Happy coding with TanStack!");
|
|
17
|
+
console.log("\n🚀 Happy coding with TanStack Router!");
|
|
63
18
|
} catch (error) {
|
|
64
19
|
console.error("❌ Error during setup:", error.message);
|
|
65
20
|
}
|
package/package.json
CHANGED
package/src/index.ts
ADDED
|
File without changes
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "ES2020",
|
|
5
|
+
"outDir": "./dist",
|
|
6
|
+
"rootDir": "./src",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"moduleResolution": "node"
|
|
12
|
+
},
|
|
13
|
+
"include": ["./src/**/*.ts"],
|
|
14
|
+
"exclude": ["node_modules", "dist"]
|
|
15
|
+
}
|
|
16
|
+
|