Welcome to Knext - a Next.js starter template that incorporates NextAuth, styled using TailwindCSS, and utilizes SQLite with KNEX for efficient query building. Knext combines the powerful features of these technologies to streamline the setup of Next.js projects.
- Next.js - The React framework for production.
- NextAuth.js - Authentication for Next.js.
- TailwindCSS - A utility-first CSS framework for rapid UI development.
- SQLite - A C-language library that implements a small, fast, self-contained SQL database engine.
- KNEX - A SQL query builder for JavaScript.
Follow these instructions to get your copy of the starter up and running on your local machine for development and testing purposes.
Before you begin, ensure you have npm installed on your system. You can install it from npmjs.com.
-
Clone the repository:
git clone git@github.com:martin2844/knext.git
-
Navigate to the project directory:
cd knext
-
Install dependencies:
npm i
-
Start the development server:
npm run dev
Now, your server should be running on http://localhost:3000. Open your browser and visit the address to see your starter in action!
This starter uses KNEX for managing database migrations, which helps in version controlling your database schema. Below are the commands available in package.json
to handle migrations:
npm run migrate:make <name>
: Create a new migration file with the specified<name>
. This is where you define changes to your database schema.npm run migrate:latest
: Apply all pending migrations to your database. This updates your schema to the latest version.npm run migrate:rollback
: Roll back the last batch of migrations, allowing you to undo recent changes to the schema.
Included in this starter is a migration for setting up a users
table, tailored to work with NextAuth. Here's what the migration scripts look like:
exports.up = function (knex) {
return knex.schema
.createTable("users", (table) => {
table.string("id").primary();
table.string("name").notNullable();
table.string("email").notNullable();
table.string("image");
})
.then(() => console.log("Migration done"));
};
exports.down = function (knex) {
return knex.schema
.dropTable("users")
.then(() => console.log("Rollback done"));
};
These migrations are crucial for managing the user data associated with the GitHub auth provider via NextAuth.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
- Hat tip to anyone whose code was used
- Inspiration
- etc
We hope you enjoy using Knext as much as we enjoyed creating it! 🚀