10BC0 GitHub - Webflow-Examples/better-auth-on-page-sso
[go: up one dir, main page]

Skip to content

Webflow-Examples/better-auth-on-page-sso

Repository files navigation

NextJS + OpenNextJS Cloudflare + Drizzle ORM + D1 + BetterAuth Example

A simple authentication scaffold using NextJS, OpenNextJS Cloudflare, Drizzle ORM, D1, and BetterAuth.

Overview

This example demonstrates a basic web application with user signup, login, and a protected homepage.

Getting Started

  1. Clone the repo git clone https://github.com/webflow/cloud-d1-examples.git
  2. Remove the current git repo so you can create your own rm -rf .git
  3. Navigate to the scaffold cd cloud-d1-examples/nextjs/betterauth-d1-example
  4. npm install

Deploy to Webflow Cloud:

  1. Push to a new GitHub repository
  2. Create a Cloud project + environment
  3. Copy and send your environmentId to Slack #triage-wf-cloud to be added to the feature flag (we can get the environmentId from the URL on your Environment details page or from your Webflow site domain)
  4. Add environment variables to your environment:
  • BETTER_AUTH_URL=https://your-domain.webflow.io (don't include a trailing / nor your mount path)
  • BETTER_AUTH_SECRET= Run command openssl rand -base64 32 to generate a random secret locally
  1. Deploy the project by pushing a new commit or clicking "Deploy from latest commit" in the Webflow Cloud dashboard

Running Locally

If you want to run locally (not required) follow these steps

  1. Copy .dev.vars.template to .dev.vars and fill in the required values:

    BETTER_AUTH_SECRET=YOUR_SECRET_HERE
    BETTER_AUTH_URL=http://localhost:8787
    
    • Generate BETTER_AUTH_SECRET using openssl rand -base64 32
  2. Apply local database migrations:

    npm run db:apply:local
  3. Start the preview:

    npm run preview

That's it! The application is now running locally, with a mimicked D1 database.

Schema Changes

If you modify the database schema:

  1. Generate new migrations:
    npm run db:generate
  2. Apply the new migrations:
    npm run db:apply:local

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0