Giter Club home page Giter Club logo

drizzleorm-lucia-template's Introduction

Template

A Next.js 13 application with authentication and payments, built with PlanetScale, Drizzle ORM, Lucia, Tailwind and LemonSqueezy

template.mp4

About this project

I used this as a way to play around with the new Next.js app directory, so it is more than likely that things aren't optimal / implemented correctly, so keep this in mind if you decide to fork it and use it for a real app

If you encounter something that's broken, you can message me @amosbastian or create an issue here. Contributions are also very much welcome! ๐Ÿ˜

Features

  • Nearly everything included in the Next.js app directory
  • TypeScript ORM for SQL databases: Drizzle ORM
  • Authentication using Lucia
  • Database on PlanetScale
  • UI components from shadcn/ui
  • Blog using MDX and Contentlayer
  • Subscriptions using LemonSqueezy
  • Styled using Tailwind CSS
  • Fetching data using RSCs and tRPC
  • Email verification
  • Teams with team member management
  • RBAC using CASL
  • Emails using Mailing

Known Issues

A list of things not working or implemented right now:

  1. Sometimes MySQL will complain about too many connections: restart your Next.js app and it will go away
  2. Pricing plans currently aren't synced to the database, which would be ideal
  3. RBAC might not work as intended and I haven't tested it enough
  4. Not using tRPC in RSCs, so not sure if that works properly
  5. Importing MJML breaks the new app router, which is why we put the email sending part in the /pages directory

Running Locally

  1. Install dependencies using npm:
npm install
  1. Copy .env.example to .env and update the variables
cp .env.example .env
  1. Start the development server:
npx nx serve web

Setting up the database

Local

  1. Log in to MySQL
mysql -u root
  1. Create the database
CREATE DATABASE template;
  1. Push your schema
npx drizzle-kit mysql:push

PlanetScale

You don't have to use a local database and use PlanetScale as your only database if you want

TODO:

Authentication

To set up GitHub OAuth you need to

  1. Go to https://github.com/settings/developers

  2. Click "New OAuth App"

  3. Add your authorisation callback URL: http://localhost:4200/api/oauth/github

Emails

You can run Mailing to get a preview of the email in development mode instead of actually sending an email

npx mailing

Payments

We are using LemonSqueezy for payments and syncing subscriptions via a webhook (lemonsqueezy/route.ts). If you want to test this locally, then you will need to use something like ngrok to expose the webhook:

npx ngrok http 4200

And then add the webhook URL (e.g. https://abc.eu.ngrok.io/api/lemonsqueezy) to your webhook settings in LemonSqueezy

Asset generation

To generate assets (favicon etc.) with your own logo you can replace logo-mark.svg with your and then use the following command

npm run asset-generator

Thanks to

License

Licensed under the MIT license.

drizzleorm-lucia-template's People

Contributors

amosbastian avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.