Next.jsReact启动器

template-nextjs-memberstack — Next.js 启动器模板

作者 raqlo

基于 Next.js 的 Memberstack 集成起始模板,演示客户端 AuthProvider 与服务器端 Server Actions 两种认证接入方式,并提供受保护路由的中间件实现。

看看你的网站会是什么样

浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。

2 个预览视图
桌面端首页1 / 2
桌面端截图首屏预览

由服务器浏览器实际访问页面后截取。

全部页面与视图 2

截图用于了解视觉与布局,交互效果请以实际项目为准。

采集于 2026-10-14查看来源

值得关注的模板亮点

从已有项目资料中,快速了解它的特点。

01

演示 Memberstack 客户端 AuthProvider 与 React hooks 的接入方式

02

演示使用 Next.js server actions 处理注册等认证流程

03

包含 login、sign-up、profile 及资料更新表单的示例实现

04

使用服务端中间件保护路由,并说明可改用客户端 Protected Route Provider

05

README 说明代码基于已弃用的原 Memberstack NextJS 库修改,以兼容 Next.js v15 的 server actions

模板详细介绍

该模板用于在 Next.js 应用中接入 Memberstack,提供认证、用户管理与会员功能的起点。README 说明它演示两种集成方式:一是用 Memberstack 的 AuthProvider 包裹主布局或根组件,在客户端管理认证状态并通过 React hooks 访问用户数据;二是用 Next.js server actions 处理认证流程、路由保护和服务端 API。模板中 login 与 profile(含资料更新表单)采用客户端方式,sign-up 采用 server actions 方式。路由保护使用服务端中间件,README 也提到可改用客户端 Protected Route Provider。README 未提供依赖清单、具体框架版本号、测试与部署流程,也未说明生产环境下的性能或安全保证。

Next.jsReact启动器

适合你的项目吗?

适用场景

  • 在 Next.js 项目中快速接入 Memberstack 认证与会员功能
  • 对比客户端 AuthProvider 与服务端 server actions 两种认证实现方式
  • 为需要登录后才能访问的页面配置路由保护

适合人群

  • 使用 Next.js 并计划集成 Memberstack 的开发者
  • 希望参考客户端与服务端两种认证接入方式的开发者
  • 需要登录、注册和用户资料页面起点的项目

上手与定制指南

结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。

  1. 1

    在 Memberstack Dashboard 创建应用,从 Dev Tools 获取 Public Key 并写入 .env 的 NEXT_PUBLIC_MEMBERSTACK_PUBLIC_KEY

  2. 2

    测试模式的 Public Key 以 pb_sb_ 开头,生产模式以 pb_ 开头,需按当前模式使用对应密钥

  3. 3

    使用 npm run dev、yarn dev、pnpm dev 或 bun dev 启动开发服务器,访问 http://localhost:3000

  4. 4

    如需 IDE 调试,可将调试器配置为监听 9230 端口

  5. 5

    README 未提供构建、测试与部署步骤

查看仓库使用说明

授权与来源资料

使用条件与限制

免费使用 · 保留许可声明

本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。

使用时需要遵守

  • 允许免费使用、修改、商用和分发该版本代码。
  • 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
  • 代码按现状提供;担保与责任限制以原许可证及适用法律为准。

额外费用与待核对事项

  • 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
  • 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
  • 使用前需在 Memberstack Dashboard 创建应用,并获取该应用的 Public Key 才能运行。
  • 必须将 Memberstack 的 Public Key 写入 .env 的 NEXT_PUBLIC_MEMBERSTACK_PUBLIC_KEY 才能正常使用。
  • 测试模式下 Public Key 以 pb_sb_ 开头,生产模式以 pb_ 开头,需按当前模式使用对应密钥。
  • 必须根据应用当前所处的模式(测试或生产)选用匹配的 Public Key。
查看原文依据

Permission is hereby granted, free of charge

许可证原文

If you haven't already, navigate to the [Memberstack Dashboard](https://app.memberstack.com) and create a new app. You can name it whatever you like—for this example, we'll use `nextjs-memberstack`.

README 原文

Go to the **Dev Tools** tab of your newly created app. Locate your **Public Key** and copy it. Then, add the key to your `.env` file in your project:

README 原文

- When in **Test Mode**, the public key will be prefixed with `pb_sb_`.

README 原文

Ensure you are using the appropriate key based on your app's current mode.

README 原文
https://github.com/raqlo/template-nextjs-memberstack/blob/main/LICENSEhttps://github.com/raqlo/template-nextjs-memberstack/blob/main/README.md

DeepSeek 根据仓库许可证和 README 整理 ·2026-10-14。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。

项目核对记录与介绍依据

模板资料

来源平台
GitHub
资料与维护参考分
资料较完整 · 82 / 100
技术栈
Next.js · React
网站类型
启动器
这个分数如何计算

本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。

这个项目需要核对什么

记录的仓库更新时间
2025-03-19
截图检查日期
2026-10-14

已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。

目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。

查看具体选型方法 →

介绍的制作与核对状态

介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。

审核声明: codex-user-requested-batch-review-20261015 · 2026-10-15

查看当时使用的来源资料

SHA-256: 59fb46d8b982e47cf0f17deae18fba94ca7a31176b50f9bde12db6362a2bfb47

2026-10-14T05:52:06.336Z

来源文件 / 仓库
# Next.js Memberstack Starter Template
This project provides a simple and effective starting point for integrating **Memberstack** into your **Next.js** application.
With this template, you can quickly set up a secure and scalable app, leveraging Memberstack’s features for authentication, user management, and membership functionality.

- **Demo**: [template-nextjs-memberstack.vercel.app](https://template-nextjs-memberstack.vercel.app/)

## Getting Started

### Creating Up Your Memberstack App
1. **Create a New App** <br />
   If you haven't already, navigate to the [Memberstack Dashboard](https://app.memberstack.com) and create a new app. You can name it whatever you like—for this example, we'll use `nextjs-memberstack`.

2. **Retrieve Your Public Key** <br />
   Go to the **Dev Tools** tab of your newly created app. Locate your **Public Key** and copy it. Then, add the key to your `.env` file in your project:
    ```dotenv
       NEXT_PUBLIC_MEMBERSTACK_PUBLIC_KEY=pb_...
    ```
3. **Test and Production Keys**
    - When in **Test Mode**, the public key will be prefixed with `pb_sb_`.
    - When in **Production Mode**, it will be prefixed with `pb_`.

Ensure you are using the appropriate key based on your app's current mode.

### Run development server

To start the development server, use one of the following commands depending on your on your package manager:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```
Once the server is running, open your browser and navigate to [http://localhost:3000](http://localhost:3000) to see your app in action.

#### Using the debugger
If you want to be able to take advantage of the debugging capabilities of your IDE, you can setup your debugger to listen to port 9230 while the next process is running

## Adding Memberstack to Your NextJs Project
Adding Memberstack to Your Next.js Project
You can integrate Memberstack into your Next.js project in different ways, depending on your needs. This template demonstrates two common approaches, but you can choose the one that best fits your optimization goals or how you prefer to use Next.js.

**1. Client-Side Approach with the AuthProvider Component**   <br />For a simple, client-side authentication setup, wrap your main layout or root component with Memberstack’s AuthProvider. This approach allows you to manage authentication entirely on the client side, making it easy to access user data and authentication states throughout your app. You can also use Memberstack’s React hooks to interact with authentication features within your client components.

📌 Example in this template: The `login` and `profile` features, including the profile update form, follow this approach.

**2. Server-Side Approach with Server Actions**   <br />For enhanced security and customization, you can integrate Memberstack using Next.js server actions. This approach is useful for securely managing authentication flows, enforcing route protection, and creating custom server-side APIs that interact with Memberstack.

📌 Example in this template: The `sign-up` feature uses server actions for authentication.

Additionally, this template uses server-side middleware to protect routes, ensuring only authenticated users can access certain pages. However, you can also implement protected routes on the client side using a Protected Route Provider that restricts access based on authentication state.

This template is designed to give you a starting point, so you can see how both approaches work and decide which one best suits your project.

## Credits and Acknowledgments

This library incorporates modified pieces of code from the original Memberstack NextJS library. With the release of newer versions of NextJS, the original library was deprecated. I updated and adjusted the code to ensure compatibility with NextJS v15, enabling the use of server actions.

Special thanks to [Tailspark](https://tailspark.co/) for providing quick and easy components that make faster build times possible. The code is licensed under the MIT license.
反馈内容错误

看看同类模板

对比同技术栈与用途的模板,找到更适合的视觉与内容结构。