Remix
Directory Structure
.
├── app
│ └── root.tsx
├── package.json
├── pnpm-lock.yaml
├── tsconfig.json
└── vite.config.tsPrepare
sh
mkdir remix
cd remixInstall runtime dependencies
sh
pnpm add @remix-run/node @remix-run/react @remix-run/serve isbot@4 react react-domInstall dev dependencies
sh
pnpm add -D @remix-run/dev vite @types/reactVite Config
sh
touch vite.config.tsts
import { vitePlugin as remix } from '@remix-run/dev'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [remix()],
})TSConfig
json
{
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2022"],
"isolatedModules": true,
"esModuleInterop": true,
"jsx": "react-jsx",
"resolveJsonModule": true,
"module": "ESNext",
"moduleResolution": "Bundler",
"baseUrl": ".",
"noEmit": true,
"paths": {
"~/*": ["./app/*"]
}
}
}The Root Route
sh
mkdir app
touch app/root.tsxtsx
import { Links, Meta, Outlet, Scripts } from '@remix-run/react'
export default function App() {
return (
<html>
<head>
<link rel="icon" href="data:image/x-icon;base64,AA" />
<Meta />
<Links />
</head>
<body>
<h1>Hello world!</h1>
<Outlet />
<Scripts />
</body>
</html>
)
}Package.json
json
{
...
"scripts": {
"dev": "remix vite:dev --host"
}
...
}sh
pnpm devAccesse Browser
http://localhost:5173
SPA Mode
ts
import { vitePlugin as remix } from '@remix-run/dev'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [
remix({
ssr: false,
}),
],
})