AGENT SKILL
remix-framework
暂无简介
- License 许可
- MIT
- 最近更新
- 2026-06-24
- Stars
- ★ 67
- Forks
- 24
03 SKILL.md 正文
Remix
Routes with Data Loading
// app/routes/posts.$slug.tsx
export async function loader({ params }: LoaderFunctionArgs) {
const post = await db.post.findUnique({ where: { slug: params.slug } });
if (!post) throw new Response("Not Found", { status: 404 });
return json(post);
}
export default function PostPage() {
const post = useLoaderData<typeof loader>();
return <article><h1>{post.title}</h1><div>{post.body}</div></article>;
}
Form Actions
export async function action({ request }: ActionFunctionArgs) {
const form = await request.formData();
await db.comment.create({ data: { body: form.get('body') as string } });
return redirect('/posts');
}
export default function NewComment() {
return <Form method="post"><textarea name="body" /><button type="submit">Post</button></Form>;
}