CodeBits is a web application that allows developers to share code snippets with others. It provides all CRUD (Create, Read, Update, Delete) functions with authentication, and it is built using Next.js, Tailwind CSS, NextAuth.js, and MongoDB.
- Check out the live demo of CodeBits at codebits.jaybhogayata.me/
- User authentication using NextAuth.js with GitHub provider
- CRUD functionality for code snippets
- Dark mode using Tailwind CSS
- Search functionality for code snippets (coming soon)
- Pagination of code snippets (coming soon)
- Sorting of code snippets by date or popularity (coming soon)
- Next.js - React framework for server-side rendering, static site generation, and more
- Tailwind CSS - Utility-first CSS framework
- NextAuth.js - Authentication library for Next.js
- MongoDB - NoSQL database
To get started with CodeBits, follow these steps:
- Clone the repository:
git clone https://github.com/your-username/codebits.git
- Install the dependencies:
cd codebits
npm install
- Set up the environment variables:
Create a .env.local
file in the root of the project with the following content:
MONGODB_URI=your-mongodb-uri
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=BnQn9mNe2IsE+gbHBHdn0lzbTbh2l/ZH43Q7eocXFUE=
GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret
Replace your-mongodb-uri
, your-github-client-id
, and your-github-client-secret
with your own values.
To get the GITHUB_CLIENT_ID
and GITHUB_CLIENT_SECRET
values, follow these steps:
-
Enter a name for your application (e.g. "CodeBits").
-
Enter the
Homepage URL
ashttp://localhost:3000
andAuthorization callback URL
ashttps://localhost:3000/api/auth/callback/github
. -
Click
Register application
. -
Copy the
Client ID
andClient Secret
values and use them as theGITHUB_CLIENT_ID
andGITHUB_CLIENT_SECRET
values in your.env.local
file. -
Run the development server:
npm run dev
- Open http://localhost:3000 in your browser to see the app.
Contributions are welcome! To contribute to CodeBits, follow these steps:
- Fork the repository.
- Create a new branch:
git checkout -b my-new-branch
. - Make your changes and commit them:
git commit -am 'Add some feature'
. - Push to the branch:
git push origin my-new-branch
. - Submit a pull request.
CodeBits is MIT licensed.