Remix
#Node.js #Deno #React #Cloudflare_Workers #Netlify #あとで書く #React_Router
リンク
規約
app/routes/* - ここに配置したディレクトリやファイルの構成をもとに、routesが定義される
app/root.{jsx,tsx} - ルートレイアウト
Adapter
Remixはアダプタを提供することで様々なプラットフォームをサポートしている
公式のアダプタは@remix-run/{adapter}で配布されている (例: @remix-run/cloudflare-workers, @remix-run/expressなど)
各アダプタはcreateRequestHandler()というAPIを提供していて、これを使うことでアプリケーションをserveできる
Resource Routes
https://github.com/remix-run/remix/blob/v1.4.3/docs/guides/resource-routes.md
環境変数
remix devでサーバを起動すると、dotenvパッケージを使って環境変数が読み込まれる
remix serveの実行時はdotenvによる読み込みが行われないので注意
https://remix.run/docs/en/v1/guides/envvars
サーバサイド
Remixは、Tree-shakingによって、サーバサイド向けのコード(loader / actionなど)がブラウザ向けのバンドルに紛れ込まないように制御している
また、ファイル名に.serverを含めておくことで、Tree-shakingがうまく効かないような状況でもコンパイラがうまく取り扱ってくれるようになる (基本的に、サーバからの利用を想定したモジュールは常に.serverを付けておくとよさそう)
https://github.com/remix-run/remix/blob/v1.5.0/docs/guides/constraints.md
関連パッケージ/リポジトリ
remix-auth - Simple Authentication for Remix
remix-image - A React component for responsive images in Remix
Conform
remix-ssg - A CLI for building static sites with Remix
remix-hono - Hono middlewares for Remix
remix-fastify - Fastify server request handler for Remix
remix-koa-adapter - Koa request server handler for Remix
テンプレート
関連ページ
Next.js vs Remix