- Nexment for Vue.js / Web Component (outdated, still based on Leancloud) https://github.com/ttttonyhe/nexment-vue
- Nexment for React.js https://github.com/ttttonyhe/nexment
Choose one of the following backends:
- Create a project on Supabase
- Go to SQL Editor and run the contents of
migration/schema.sqlto create thenexment_commentstable - Go to Authentication → Providers → Email and disable "Confirm email" (required for admin registration)
- Go to Project Settings → API and copy your Project URL and Publishable key
- Create a project on Neon
- Enable Neon Auth in your project settings
- Go to SQL Editor and run the contents of
migration/schema-neon.sqlto create thenexment_commentstable with the required RLS policies and role grants - Copy your Auth URL and Data API URL from the Neon project dashboard
Add Nexment to your project:
npm install nexmentImport and use with Supabase:
import Nexment from "nexment"
const config = {
pageKey: "xxx", // optional, defaults to window.location.pathname
features: {
linkInput: true,
replyListModal: true,
replyEmailNotifications: true,
descriptionTag: true,
},
supabase: {
url: "https://your-project.supabase.co",
anonKey: "your-anon-key",
},
admin: {
name: "xxx",
email: "xxx@xxx.xxx",
},
blackList: [
{ name: "xxx", email: "xxx", keyword: "xxx", link: "xxx" },
{ keyword: "xxx" },
],
}
;<Nexment config={config} />Or with Neon:
import Nexment from "nexment"
const config = {
pageKey: "xxx",
features: {
linkInput: true,
replyListModal: true,
replyEmailNotifications: true,
descriptionTag: true,
},
neon: {
authUrl: "https://your-project.auth.neon.tech",
dataApiUrl: "https://your-project.data-api.neon.tech",
},
admin: {
name: "xxx",
email: "xxx@xxx.xxx",
},
}
;<Nexment config={config} />Create a wrapper component (using either supabase or neon config):
import Nexment from "nexment"
const NexmentComponent = () => {
const config = {
pageKey: "xxx",
features: {
linkInput: true,
replyListModal: true,
replyEmailNotifications: true,
descriptionTag: true,
},
// Use one of the following:
supabase: {
url: "https://your-project.supabase.co",
anonKey: "your-anon-key",
},
// OR
// neon: {
// authUrl: "https://your-project.auth.neon.tech",
// dataApiUrl: "https://your-project.data-api.neon.tech",
// },
admin: {
name: "xxx",
email: "xxx@xxx.xxx",
},
}
return <Nexment config={config} />
}
export default NexmentComponentImport it using next/dynamic to disable SSR:
import dynamic from "next/dynamic"
const NexmentDiv = dynamic(() => import("./NexmentComponent"), {
ssr: false,
})
const Page = () => {
return (
<div>
<NexmentDiv />
</div>
)
}
export default PageNexment supports email notifications when someone replies to a comment. To enable this, you need to:
- Set
features.replyEmailNotificationstotruein your Nexment config - Deploy one of the email endpoint handlers below
- Point
email.endpointin your config to the deployed URL
const config = {
features: {
replyEmailNotifications: true,
},
email: {
endpoint: "https://your-domain.com/api/nexment-email",
},
// ... other config
}All handlers use Resend to send emails. You'll need:
- A Resend account and API key
- A verified sending domain (or use Resend's sandbox for testing)
| Environment Variable | Description | Required |
|---|---|---|
RESEND_API_KEY |
Your Resend API key | Yes |
RESEND_FROM_ADDRESS |
Sender address (e.g. Nexment <no-reply@example.com>) |
No (has default) |
ALLOWED_ORIGIN |
CORS allowed origin | No (defaults to *) |
Copy server/nextjs/app-router.ts into your Next.js project as a route handler, for example at app/api/nexment-email/route.ts.
Copy server/nextjs/pages-router.ts into your Next.js project as an API route, for example at pages/api/nexment-email.ts.
Deploy server/worker.js as a Cloudflare Worker. Set RESEND_API_KEY and RESEND_FROM_ADDRESS as secrets via wrangler secret put.
Nexment has full TypeScript type-checking support.
If you were previously using the LeanCloud-based version of Nexment, follow these steps to migrate your data to Supabase:
Go to your LeanCloud app → Data Storage → Import/Export → Export to download a backup. The backup will contain a nexment_comments.0.jsonl file with all your comments.
Follow the Supabase setup instructions above to create the nexment_comments table.
node migration/leancloud-to-supabase.mjs <path-to-backup-dir> <output.sql>For example:
node migration/leancloud-to-supabase.mjs ./my-backup ./seed.sqlThis reads the nexment_comments.0.jsonl file from the backup directory and generates a seed.sql file containing INSERT statements for all your comments.
Paste the contents of the generated seed.sql file into the Supabase SQL Editor and run it. All your comments (including reply threading) will be preserved.
Replace the leancloud config with supabase:
const config = {
- leancloud: {
- appId: "xxx",
- appKey: "xxx",
- serverURL: "https://xxx",
- },
+ supabase: {
+ url: "https://your-project.supabase.co",
+ anonKey: "your-anon-key",
+ },
admin: {
name: "xxx",
email: "xxx@xxx.xxx",
},
};An example LeanCloud backup is included in the backup/ directory for reference.
File an issue whenever you encounter a problem, pull requests are always welcomed.
