React Router v7 已發佈。 檢視文件
create-remix (CLI)

create-remix

剛開始使用 Remix 嗎?最新版本的 Remix 現在是 React Router v7。如果您想使用最新的框架功能,應該使用 create-react-router CLI 來啟動新專案

create-remix CLI 將會建立一個新的 Remix 專案。不傳遞任何引數,這個指令將會啟動一個互動式 CLI 來設定新的專案,並將其設定在指定的目錄中。

npx create-remix@latest

您可以選擇性地傳遞所需的目錄路徑作為引數

npx create-remix@latest <projectDir>

預設應用程式是一個使用內建 Remix 應用程式伺服器的 TypeScript 應用程式。如果您希望根據不同的設定建立應用程式,您可以使用 --template 旗標

npx create-remix@latest --template <templateUrl>

要取得可用指令和旗標的完整清單,請執行

npx create-remix@latest --help

套件管理器

create-remix 也可以使用各種套件管理器來調用,讓您可以選擇 npm、Yarn、pnpm 和 Bun 來管理安裝過程。

npm create remix@latest <projectDir>
# or
yarn create remix@latest <projectDir>
# or
pnpm create remix@latest <projectDir>
# or
bunx create-remix@latest <projectDir>

create-remix --template

如需有關可用範本的更完整指南,請參閱我們的範本頁面。

有效的範本可以是

  • GitHub 儲存庫簡寫 — :username/:repo:username/:repo/:directory
  • GitHub 儲存庫的 URL(或其中的目錄)— https://github.com/:username/:repohttps://github.com/:username/:repo/tree/:branch/:directory
    • 當使用此格式時,分支名稱(:branch)不能有 /,因為 create-remix 無法區分分支名稱和目錄路徑
  • 遠端 tarball 的 URL — https://example.com/remix-template.tar.gz
  • 本機檔案路徑到檔案目錄 — ./path/to/remix-template
  • 本機檔案路徑到 tarball — ./path/to/remix-template.tar.gz
npx create-remix@latest ./my-app --template remix-run/grunge-stack
npx create-remix@latest ./my-app --template remix-run/remix/templates/remix
npx create-remix@latest ./my-app --template remix-run/examples/basic
npx create-remix@latest ./my-app --template :username/:repo
npx create-remix@latest ./my-app --template :username/:repo/:directory
npx create-remix@latest ./my-app --template https://github.com/:username/:repo
npx create-remix@latest ./my-app --template https://github.com/:username/:repo/tree/:branch
npx create-remix@latest ./my-app --template https://github.com/:username/:repo/tree/:branch/:directory
npx create-remix@latest ./my-app --template https://github.com/:username/:repo/archive/refs/tags/:tag.tar.gz
npx create-remix@latest ./my-app --template https://github.com/:username/:repo/releases/latest/download/:tag.tar.gz
npx create-remix@latest ./my-app --template https://example.com/remix-template.tar.gz
npx create-remix@latest ./my-app --template ./path/to/remix-template
npx create-remix@latest ./my-app --template ./path/to/remix-template.tar.gz

create-remix --overwrite

如果 create-remix 偵測到範本和您要建立應用程式的目錄之間有任何檔案衝突,它會提示您確認是否可以將這些檔案覆寫為範本版本。您可以使用 --overwrite CLI 旗標來跳過此提示。

文件和範例授權於 MIT