https://github.com/ev0clu/next-blog
Fullstack (Next.js) Blog App
https://github.com/ev0clu/next-blog
api bcryptjs markdown mongodb next-auth nextjs prisma-orm react-hook-form react-hook-forms react-icons simplemde tailwindcss typescript zod zod-validation
Last synced: 2 months ago
JSON representation
Fullstack (Next.js) Blog App
- Host: GitHub
- URL: https://github.com/ev0clu/next-blog
- Owner: ev0clu
- Created: 2023-10-20T12:46:35.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-19T14:17:43.000Z (over 2 years ago)
- Last Synced: 2025-01-18T02:41:22.943Z (over 1 year ago)
- Topics: api, bcryptjs, markdown, mongodb, next-auth, nextjs, prisma-orm, react-hook-form, react-hook-forms, react-icons, simplemde, tailwindcss, typescript, zod, zod-validation
- Language: TypeScript
- Homepage: https://next-blog-eight-azure.vercel.app
- Size: 408 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# **Next.js Blog**
A basic blog app has built with Next.js framework. The app allows users to log in in order to write comments under any posts.
### Demo: [Link](https://next-blog-eight-azure.vercel.app/)
## Features
- Allow user to register, log in and log out
- Only logged in users have rights to write comments
- Only users with admin rights can create a new post
- User with admin rights can remove/update posts and comments
- User without admin rigths can remove/update comments which have written by himself/herself
- Posts and comments update date has shown
- Next.js used for CSR and SSR
- MongoDB used to store users, posts and comments informations
- Prisma ORM is used
- Bcrypt.js used to hash the user password
- Zod used for validation
- Render-as-you-fetch approach is used for Loading screen
- Hosted on Vercel
- Responsive design
## How to run from local repository
1. Clone the repository
2. Run `npm install` command in your terminal
3. Set up MongoDB database
Create .env file and add enviromental variables: open ssl key should generate to NEXTAUTH_SECRET
4. Create .env file and add enviromental variables: open ssl key should generate to NEXTAUTH_SECRET
`DATABASE_URL="your-mongodb-connection-link"`
`NEXTAUTH_SECRET="open-ssl-generated-key"`
`CODE="3.1415"`
5. Run `npx prisma generate`
6. Run `npm run dev` command in your terminal
7. Server running at `http://localhost:3000/`
### Useful links and informations
- Open SSL key generation:
- You can use the following link to create open ssl key: `https://www.cryptool.org/en/cto/openssl` or you can install open ssl and generate key from terminal. To generate code you should run: `openssl rand -base64 32`
- Tailwind `prose` and `typography` handling are needed for markdowns:
- [Stackoverflow](https://stackoverflow.com/questions/75706164/problem-with-tailwind-css-when-using-the-react-markdown-component)
- [TailwindCSS official plugin](https://tailwindcss.com/docs/typography-plugin)
- Markdown editor needed to run in `use client` mode and need to be imported in dynamic to avoid navigator is not defined error:
- [Stackoverflow](https://stackoverflow.com/questions/77301109/next-navigation-giving-error-navigator-is-not-defined)
- [GitHub](https://github.com/RIP21/react-simplemde-editor/issues/30)
- SimpleMDE usage, options:
- [Usage: GitHub](https://github.com/Ionaru/easy-markdown-editor#configuration)
- [Options: Github](https://github.com/RIP21/react-simplemde-editor)
- React Hook Form usage with UI component needs to has `ref={null}` property to avoid ref warning:
- [Stackoverflow](https://stackoverflow.com/questions/67877887/react-hook-form-v7-function-components-cannot-be-given-refs-attempts-to-access)
- [GitHub](https://github.com/react-hook-form/react-hook-form/issues/3411)
- Loading screen approaches (Fetch-than-render, Render-as-you-fetch, Suspense, ):
- [Medium.com](https://medium.com/jspoint/introduction-to-react-v18-suspense-and-render-as-you-fetch-approach-1b259551a4c0)
- [Linkedin.com](https://www.linkedin.com/pulse/fetch-then-render-render-as-you-fetch-fetch-on-render-amit-pal/)
### Dependencies
- [React](https://react.dev/)
- [React DOM](https://www.npmjs.com/package/react-dom)
- [React Icons](https://www.npmjs.com/package/react-icons)
- [Typescript](https://www.typescriptlang.org/)
- [Tailwind CSS](https://tailwindcss.com/)
- [Next.js](https://nextjs.org/)
- [Next Auth](https://next-auth.js.org/)
- [Prisma](https://www.prisma.io/)
- [Prisma Adapter](https://authjs.dev/reference/adapter/prisma)
- [bcrypt](https://www.npmjs.com/package/bcrypt)
- [React Hook Form](https://react-hook-form.com/)
- [@hookform/resolvers](https://www.npmjs.com/package/@hookform/resolvers)
- [Zod](https://zod.dev/)
- [SimpleMDE (EasyMDE)](https://www.npmjs.com/package/react-simplemde-editor)
- [React Markdown](https://www.npmjs.com/package/react-markdown)
- [date-fns](https://date-fns.org/)
### Layout


