Notion-Paywall is a plug-n-play serverless Next.js boilerplate. It consists of two main parts.
/api/auth
to hide the paywall; powered by NextAuth.js/api/checkout_sessions
to generate Stripe Checkout links/api/webhooks
to listen to Stripe charge_succeeded
events/api/upsert_user
to store newly created customers/api/send_email
to send “welcome” and “sign-in” emails/api/notify_slack
to send bot messages to SlackNotion-Paywall uses the notion-client
package. It uses the token_v2
cookie to talk to Notion’s backend and request your Notion content.
To retrieve your personal token, you’ll need to sign into Notion.com via the browser — not the Mac/Windows/phone app!
You’ll need a database connection to store your customers’ emails and their sign-in sessions.
Notion-Paywall uses Prisma.io to abstract all user auth database operations away. It ships with a schema.prisma
that connects to MongoDB but you can easily opt for MySQL, Postgres, and other vendors. If you’re new to this, setting up a MongoDB cluster is [super easy](https://www.mongodb.com/docs/atlas/cluster-tier/](https://www.mongodb.com/docs/atlas/cluster-tier/).
schema.prisma
config file looks like this:Notion-Paywall sends emails through the nodemailer
package so you’ll need an SMTP transporter. All major email players support this…
Notion-Paywall talks to your Stripe account via the publishable key from the frontend and the secret key from the backend. Stripe, in turns, talks to Notion-Paywall via webhooks which need to be verified to prevent malicious activity.