next-secure
v1.0.7
Published
A CLI tool to add authentication to a Next.js project
Readme
next-secure-cli
next-secure
next-secure is a CLI tool to add authentication to your Next.js project. It helps you set up authentication components, configuration files, and run necessary installation commands with ease.
Installation
You can install next-secure globally using npm:
npm install -g next-secureAlternatively, you can use npx to run it without installing globally:
npx next-secureUsage
Run next-secure in your Next.js project directory to set up authentication:
-helporh: Display help information.
What It Does
- Copies Directories:
- Copies the
publicdirectory from thetemplatefolder to your project, skipping existing files. - Copies the
_schemasdirectory from thetemplatefolder to your project root. - Copies the contents of the
srcdirectory from thetemplatefolder to the existingsrcdirectory in your project, or to the root ifsrcdoes not exist.
- Copies the
- Installs Dependencies:
- Installs
next-auth@beta,nodemailer,@prisma/client,@auth/prisma-adapter, andprisma.
- Installs
- Runs Initialization Commands:
- Initializes
shadcnwith a set of components. - Initializes Prisma.
- Initializes
- Creates Configuration Files:
- Creates or appends to
.envand.env.localwith necessary configuration settings.
- Creates or appends to
Configuration
After running next-secure, you need to:
- Generate Auth Secret:
- Run
openssl rand -base64 32to generate the auth secret.
- Run
- Update
.envand.env.local:- Add OAuth provider details, email provider details, and database URL to the respective
.envfiles.
- Add OAuth provider details, email provider details, and database URL to the respective
- Add OAuth Providers:
- Configure the OAuth providers in
@/auth/provider.js.
- Configure the OAuth providers in
Documentation
For more details and advanced usage, please refer to the documentation.
License
This project is licensed under the ISC License - see the LICENSE file for details.
Contributing
If you would like to contribute to this project, please submit a pull request or open an issue.
