GithubHelp home page GithubHelp logo

huv1k / nextjs-auth-prisma Goto Github PK

View Code? Open in Web Editor NEW
154.0 4.0 7.0 1.97 MB

Full-stack boilerplate template.

Home Page: https://nextjs-auth-prisma.huvik.dev

Shell 0.58% TypeScript 93.89% JavaScript 5.53%
react nextjs typescript graphql prisma nextauth urql helix

nextjs-auth-prisma's Introduction

Next.js-auth-prisma boilerplate

Build bleeding-edge full-stack applications using Next.js, GraphQL, TypeScript and Prisma.

Getting started

  1. Clone this project git clone https://github.com/huv1k/nextjs-auth-prisma
  2. Install dependencies yarn install or npm install
  3. Setup your local environment
  4. Run application yarn dev or npm run dev
  5. Profit ๐Ÿ’ฐ

Features

  • ๐Ÿฃ Simple: You can focus on building your product.
  • โšก๏ธ Fast: Compile only what is needed and when is needed.
  • ๐Ÿ’ Feature-rich: Code generation, automatic migrations, type-safety.
  • ๐Ÿ›  Customizable: You can easily change tools you are not familiar with.

Overview

I have created this boilerplate because there was a missing one with all features. Which would support fast development and easy deployment without sacrificing performance. This boilerplate is built on the best open-source tools out there:

  • โšก๏ธ Next.js - The React framework for Production
  • ๐Ÿ›  TypeScript - Type-safety for your code
  • ๐Ÿค Prisma - ORM for accessing and managing your data
  • ๐Ÿ›ก NextAuth.js - Authentication for Next.js
  • ๐Ÿฆ… urql - Highly customisable GraphQL client with sensitive defaults
  • โš™๏ธ GraphQL Code Generator - Generates code out of GraphQL schema
  • ๐Ÿง˜โ€โ™€๏ธ GraphQL Yoga - Fully-featured GraphQL Server
  • ๐Ÿ’„ Prettier - Formatting your code
  • ๐Ÿค– Dependabot - Keeping your dependencies up to date

Run Prisma migrations on save

This boilerplate works out of the box with automatic migrations for rapid prototyping. I described this in my article Improve prototyping speed of Prisma, you can check how it works under the hood.

Automatic GraphQL types generated

GraphQL types are automatically generated for data masking. This pattern is one of the best practise you should follow when building scalable applications. This pattern was first introduced by Relay.

Authentication using NextAuth.js

This boilerplate is configured to use GitHub authentication provider. NextAuth.js comes with a lot of different providers. You can choose, which providers suit your needs most.

Defining custom authorization rules

You can define authorization rules for your resolvers. You can follow Pothos's auth plugin documentation or checkout example in this repository.

Deployment

For deployment, you can use Vercel, this boilerplate works with Vercel out of the box! Use this template and then import Git repository inside Vercel dashboard.

Setup

Connect your database

This starter could be used with all databases supported by Prisma. I would suggest using PlanetScale, which has a nice generous free plan. You can follow Prisma getting started to get your database up and running.

NextAuth GitHub provider

You need to create GitHub OAuth App. You're going to provide Authorization callback URL like:

  • Local development: http://localhost:3000/api/auth
  • Production deployment: https://www.YOURDOMAIN.TLD/api/auth

Then you are going to copy Client ID and Client secret and fill your environment variables.

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.