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.
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 [email protected]: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.
To run the application using Docker, follow these steps:
Build the Docker image:
docker build -t knext .
Run the container:
docker run -p 3000:3000 knext
Alternatively, you can use Docker Compose for a more streamlined setup:
docker-compose up
This will build the image if it doesn't exist and start the container. The application will be accessible at http://localhost:3000.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)Distributed under the MIT License. See LICENSE
for more information.
We hope you enjoy using Knext as much as we enjoyed creating it! 🚀