Remix Supa Fly Stack 项目教程

Remix Supa Fly Stack 项目教程

supa-fly-stackThe Remix Stack for deploying to Fly with Supabase, authentication, testing, linting, formatting, etc.项目地址:https://gitcode.com/gh_mirrors/su/supa-fly-stack

1. 项目的目录结构及介绍

supa-fly-stack/
├── app/
│   ├── entry.client.tsx
│   ├── entry.server.tsx
│   ├── root.tsx
│   ├── routes/
│   │   ├── __auth.tsx
│   │   ├── __notes.tsx
│   │   ├── index.tsx
│   ├── modules/
│   │   ├── auth/
│   │   │   ├── session.ts
│   │   ├── note/
│   │   │   ├── note.ts
├── cypress/
│   ├── integration/
│   ├── plugins/
│   ├── support/
├── public/
│   ├── favicon.ico
├── supabase/
│   ├── config.ts
├── test/
│   ├── setup.ts
├── .dockerignore
├── .env.example
├── .eslintignore
├── .eslintrc
├── .gitignore
├── .prettierignore
├── .prettierrc.cjs
├── Dockerfile
├── fly.toml
├── package.json
├── postcss.config.mjs
├── README.md
├── remix.config.js
├── remix.env.d.ts
├── tailwind.config.ts
├── tsconfig.json
├── vitest.config.ts

目录结构介绍

  • app/: 包含应用程序的主要代码,包括客户端和服务器入口文件、根组件和路由。
    • entry.client.tsx: 客户端入口文件。
    • entry.server.tsx: 服务器入口文件。
    • root.tsx: 根组件。
    • routes/: 路由文件。
    • modules/: 模块文件,包括认证和笔记模块。
  • cypress/: 端到端测试相关文件。
  • public/: 公共静态资源文件。
  • supabase/: Supabase 配置文件。
  • test/: 测试设置文件。
  • 配置文件和忽略文件:.dockerignore, .env.example, .eslintignore, .eslintrc, .gitignore, .prettierignore, .prettierrc.cjs, Dockerfile, fly.toml, package.json, postcss.config.mjs, README.md, remix.config.js, remix.env.d.ts, tailwind.config.ts, tsconfig.json, vitest.config.ts

2. 项目的启动文件介绍

客户端入口文件

app/entry.client.tsx:

import { RemixBrowser } from "@remix-run/react";
import { startTransition, StrictMode } from "react";
import { hydrateRoot } from "react-dom/client";

startTransition(() => {
  hydrateRoot(
    document,
    <StrictMode>
      <RemixBrowser />
    </StrictMode>
  );
});

服务器入口文件

app/entry.server.tsx:

import { renderToString } from "react-dom/server";
import { RemixServer } from "remix";
import type { EntryContext } from "remix";

export default function handleRequest(
  request: Request,
  responseStatusCode: number,
  responseHeaders: Headers,
  remixContext: EntryContext
) {
  const markup = renderToString(
    <RemixServer context={remixContext} url={request.url} />
  );

  responseHeaders.set("Content-Type", "text/html");

  return new Response("<!DOCTYPE html>" + markup, {
    status: responseStatusCode,
    headers: responseHeaders,
  });
}

根组件

app/root.tsx:

import { Links, LiveReload, Meta, Outlet, Scripts, ScrollRestoration } from "remix";

export default function App() {
  return (
    <html lang="en">
      <head>
        <meta charSet="utf-8" />
        <meta name="viewport" content="width=device-width,initial-scale=1" />
        <Meta />
        <Links />
      </head>
      <body>
        <Outlet />
        <Scroll

supa-fly-stackThe Remix Stack for deploying to Fly with Supabase, authentication, testing, linting, formatting, etc.项目地址:https://gitcode.com/gh_mirrors/su/supa-fly-stack

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夏磊讳

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值