{"id":14968820,"url":"https://github.com/bruceluos/nextjs-supabase-cloudflare","last_synced_at":"2025-10-26T05:30:46.275Z","repository":{"id":253635229,"uuid":"844019870","full_name":"BruceLuos/nextjs-supabase-cloudflare","owner":"BruceLuos","description":"maybe is a nextjs project with supabase deploy in cloudflare page simple template ?","archived":false,"fork":false,"pushed_at":"2024-08-24T03:36:49.000Z","size":439,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T15:52:39.461Z","etag":null,"topics":["cloudflare-pages","contentlayer","flowbite-react","next-intl","nextjs","stripe","supabase"],"latest_commit_sha":null,"homepage":"https://nextjs-supabase-cloudflare.pages.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BruceLuos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-18T06:05:15.000Z","updated_at":"2025-03-08T06:22:46.000Z","dependencies_parsed_at":"2024-08-18T11:45:41.679Z","dependency_job_id":"1b8d5df6-44a2-40b9-88f2-d6879dde6fad","html_url":"https://github.com/BruceLuos/nextjs-supabase-cloudflare","commit_stats":null,"previous_names":["bruceluos/nextjs-supabase-cloudflare"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BruceLuos/nextjs-supabase-cloudflare","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BruceLuos%2Fnextjs-supabase-cloudflare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BruceLuos%2Fnextjs-supabase-cloudflare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BruceLuos%2Fnextjs-supabase-cloudflare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BruceLuos%2Fnextjs-supabase-cloudflare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BruceLuos","download_url":"https://codeload.github.com/BruceLuos/nextjs-supabase-cloudflare/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BruceLuos%2Fnextjs-supabase-cloudflare/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281060126,"owners_count":26437157,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-26T02:00:06.575Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudflare-pages","contentlayer","flowbite-react","next-intl","nextjs","stripe","supabase"],"created_at":"2024-09-24T13:40:37.246Z","updated_at":"2025-10-26T05:30:45.876Z","avatar_url":"https://github.com/BruceLuos.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Getting Started\n\n```bash\nnpm run dev\n# or\nyarn dev\n# or\npnpm dev\n# or\nbun dev\n```\n\n## 项目描述\n\n- 项目框架 Next.js\n\n- Ui库 Flowbite\n\n  - 全局toast `components/ui/FlowbiteToasts`\n\n- 后端服务 Supabase\n\n  - supabase 相关方法 `utils/supabase`\n  - 登录方法,项目目前使用邮箱otp和谷歌oauth `utils/auth-helpers`\n  - 谷歌登录回调 `auth/callback`\n\n- 支付服务 Stripe\n\n  - stripe 相关方法 `utils/stripe`\n  - stripe webhook `api/webhook`\n  - stripe 产品数据获取并展示 `components/PricingSection`\n\n- 博客 Contentlayer 和 MDX\n\n  - 博客内容 `content/blog`\n  - contentlayer 配置 `contentlayer.config.js`\n\n- 国际化i18n Next-intl\n\n  - 配置文件 `i18n.ts | navigation.ts`\n  - en无前缀Link组件 `components/Link`\n\n- 统计脚本\n\n  - `\u003cAnalyticsScript/\u003e`\n\n- sitemap生成\n\n  - `sitempa.ts`\n\n- metadata生成\n\n  - 简易生成使用 `seo.tsx`\n  - 定制生成 `generateMetadata`\n\n- 其他\n  - Header nav 文本和路径对应`NavBar 和 NavBarWithoutLocale 中的navLink`\n  - 部分公共配置 `config.js`\n\n## stripe webhook 本地调试\n\nhttps://dashboard.stripe.com/webhooks/create?endpoint_location=local\nhttps://docs.stripe.com/stripe-cli\n\n```\nstripe login\nstripe listen --forward-to localhost:3000/api/webhook\n```\n\n## stripe 支付 test\n\n- 选择随机一个付费方案，Premium或Basic\n- 填入银行卡信息\n  - 银行卡号：4242 4242 4242 4242\n  - 年份随机 如：8/27\n  - cvc随机 如：344\n  - 名字和国家也随机填入\n  - 支付成功\n  - 账号积分增加\n\n## supabase 数据库表sql\n\n```sql\n-- 用户表\ncreate table users (\n    --  用户id,取auth表中id\n    id uuid references auth.users not null primary key,\n    -- stripe顾客id\n    stripe_customer_id text,\n    -- 用户名\n    username text,\n    -- 用户头像\n    avatar_url text,\n    -- 用户邮箱\n    email text,\n    -- 当前总积分,默认10\n    plan_limit decimal(10,2) default 10.00,\n    -- 用户使用积分\n    plan_used decimal(10,2) default 0.00,\n    -- 用户今天使用积分数\n    today_used decimal(10,2) default 0.00,\n    -- 用户总共使用积分数\n    total_used decimal(10,2) default 0.00,\n    -- 套餐类型    0为普通用户，1为消费用户\n    plan_type integer default 0,\n    -- 套餐过期时间\n    plan_expire_at timestamp with time zone,\n    -- 用户总消费\n    paid_amount decimal(10,2) default 0.00,\n    -- 记录的创建时间\n    created_at timestamp with time zone default timezone('utc'::text, now()) not null,\n    -- 记录的更新时间\n    updated_at timestamp with time zone default timezone('utc'::text, now()) not null\n\n);\n\n\n-- 订单状态类型 stripe order status\ncreate type order_status_type as enum ('processing', 'canceled','succeeded','requires_action','requires_capture','requires_confirmation','requires_payment_method');\n\n-- 订单表\ncreate table orders (\n    -- 自增id\n    id serial primary key,\n    -- 用户id, 取auth表中id\n    user_id uuid references auth.users not null,\n    -- 账单id\n    trade_id text,\n    -- stripe顾客id\n    stripe_customer_id text,\n    -- 账单状态, processing, canceled, succeeded\n    status order_status_type,\n    -- 价格\n    amount bigint,\n    -- 货币\n    currency text,\n    -- 商品id,套餐id\n    product_id text,\n    -- 商品名\n    product_name text,\n    -- 商品描述\n    product_description text,\n    -- 支付时间,\n    paid_time timestamp with time zone,\n    -- 账单创建日期\n    date timestamp with time zone,\n    -- 记录的创建时间\n    created_at timestamp with time zone default timezone('utc'::text, now()) not null,\n    -- 记录的更新时间\n    updated_at timestamp with time zone default timezone('utc'::text, now()) not null\n );\n\n\n\n/**\n* trigger 新注册用户自动往users表插入一定数据\n*/\n-- trigger 已存在则删除\ndrop function if exists public.handle_new_user ();\ncreate function public.handle_new_user()\nreturns trigger as\n$$\ndeclare\n    final_username text;\n    suffix_counter int := 1;\nbegin\n    -- 提取邮箱前缀并去除非字母数字字符\n    select regexp_replace(substring(new.email from '^[^@]+'), '[^a-z0-9]', '', 'g') into final_username;\n\n    -- 去除所有空格部分\n    final_username := replace(final_username, ' ', '');\n\n    -- 已存在username 处理为username_1_2_3\n    while exists (\n        select 1 from public.users where lower(username) = lower(final_username)\n    ) loop\n        final_username := final_username || '_' || suffix_counter;\n        suffix_counter := suffix_counter + 1;\n    end loop;\n\n    insert into public.users (id, username, avatar_url, email)\n    values (\n      new.id,\n      final_username,\n      -- 如果没有提供avatar_url，使用'默认头像URL'\n      coalesce(new.raw_user_meta_data-\u003e\u003e'avatar_url', ''),\n      new.email\n    );\n    return new;\nend;\n\n$$\nlanguage plpgsql security definer;\n\ncreate trigger on_auth_user_created\n  after insert on auth.users\n  for each row\n    execute procedure public.handle_new_user();\n\n\n\n```\n\n## supabase [谷歌登录配置](https://supabase.com/docs/guides/auth/social-login/auth-google#configure-your-services-id)\n\n## supabase [邮箱otp登录配置](https://supabase.com/docs/guides/auth/auth-email-passwordless)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbruceluos%2Fnextjs-supabase-cloudflare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbruceluos%2Fnextjs-supabase-cloudflare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbruceluos%2Fnextjs-supabase-cloudflare/lists"}