0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Remixを学びたい(Step1: 基本的なセットアップとルーティング)

Last updated at Posted at 2025-04-29

はじめに

Remixを学びたいのStep1です。Todoアプリを最終的に完成させようと思います!!

シリーズもの

成果物

todo step1 .gif

今回はTODOアプリのページのみを作成します。静的なページを作成するため、ボタンのアクションは有効化していません。
今回作成したものは下記githubにあります

Hands-onスタート

プロジェクトを作成
~/develop/remix_sample  (HEAD)$ npx create-remix@latest .
tailwindのセットアップ
~/develop/remix_sample  (main)$ npm install -D tailwindcss postcss autopref
ixer

up to date, audited 855 packages in 2s

268 packages are looking for funding
  run `npm fund` for details

7 moderate severity vulnerabilities

To address issues that do not require attention, run:
  npm audit fix

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.
~/develop/remix_sample  (main)$ npx tailwindcss init -p

Created Tailwind CSS config file: tailwind.config.js
postcss.config.js already exists.
app/routes/_index.tsx
import type { MetaFunction } from "@remix-run/node";

export const meta: MetaFunction = () => {
	return [
		{ title: "New Remix App" },
		{ name: "description", content: "Welcome to Remix!" },
	];
};

export default function Index() {
	const todos = [
		{ id: 1, title: "Remixを学ぶ", completed: false },
		{ id: 2, title: "TODOアプリを作る", completed: true },
		{ id: 3, title: "コードを理解する", completed: false },
	];

	return (
		<div className="max-w-2xl mx-auto p-4">
			<h1 className="text-2xl font-bold mb-4">TODO App</h1>

			{/* TODO追加フォーム */}
			<div className="mb-4">
				<input
					type="text"
					placeholder="新しいTODOを入力"
					className="w-full p-2 border rounded"
				/>
			</div>

			{/* TODOリスト */}
			<ul className="space-y-2">
				{todos.map((todo) => (
					<li
						key={todo.id}
						className="flex items-center justify-between p-3 bg-white border rounded shadow-sm"
					>
						<div className="flex items-center gap-2">
							<input
								type="checkbox"
								checked={todo.completed}
								className="h-4 w-4"
							/>
							<span
								className={todo.completed ? "line-through text-gray-500" : ""}
							>
								{todo.title}
							</span>
						</div>
						<button className="text-red-500 hover:text-red-700">削除</button>
					</li>
				))}
			</ul>
		</div>
	);
}

→indexページを作成しました。
静的なページのため、ただレンダリングを実施しているだけです

さいごに

今回は静的なページを表示するだけでした。次はサーバとの疎通をやってみたいと思います!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?