sanidhyy / messenger-clone

A Real-Time Messenger Clone using Next.js 14.

Home Page:https://appmessenger.vercel.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Messenger Clone - A Real-Time Messaging App using Next.js 14.

Messenger Clone - A Real-Time Messaging App using Next.js 14.

Ask Me Anything! GitHub license Maintenance GitHub branches Github commits Vercel status GitHub issues GitHub pull requests

πŸ“” Table of Contents

‼️ Folder Structure

Here is the folder structure of this app.

messenger-clone/
  |- app/
    |-- (site)/
        |--- components/
        |--- page.tsx
    |-- actions/
        |--- get-conversation-by-id.ts
        |--- get-conversation.ts
        |--- get-current-user.ts
        |--- get-messages.ts
        |--- get-session.ts
        |--- get-users.ts
    |-- api/
        |--- auth/[...nextauth]
        |--- conversations/[conversationId]
        |--- messages/
        |--- pusher/
        |--- register/
        |--- settings/
    |-- components/
        |--- inputs/
        |--- modals/
        |--- sidebar/
        |--- active-status.tsx
        |--- avatar-group.tsx
        |--- avatar.tsx
        |--- button.tsx
        |--- empty-state.tsx
        |--- loading-modal.tsx
    |-- config/
        |--- authOptions.tsx
        |--- site.ts
    |-- context/
        |--- auth-context.ts
        |--- toaster-context.ts
    |-- conversations/
        |--- [conversationId]/
            |---- components/
        |--- components/
        |--- layout.tsx
        |--- loading.tsx
        |--- page.tsx
    |-- hooks/
        |--- use-active-channel.tsx
        |--- use-active-list.tsx
        |--- use-conversation.tsx
        |--- use-other-user.tsx
        |--- use-routes.tsx
    |-- libs/
        |--- prismadb.ts
        |--- pusher.ts
    |-- types/
        |--- index.ts
    |-- users/
        |--- components/
        |--- layout.tsx
        |--- loading.tsx
        |--- page.tsx
    |-- favicon.ico
    |-- globals.css
    |-- layout.tsx
  |- prisma/
    |-- schema.prisma
  |- public/
    |-- images/
        |--- logo.png
        |--- placeholder.jpg
  |- .env
  |- .env.example
  |- .eslintrc.json
  |- .gitignore
  |- middleware.ts
  |- next.config.js
  |- package-lock.json
  |- package.json
  |- postcss.config.js
  |- tailwind.config.ts
  |- tsconfig.json

🧰 Getting Started

  1. Make sure Git and NodeJS is installed.
  2. Clone this repository to your local computer.
  3. Create .env file in root directory.
  4. Contents of .env:
# .env

# mongodb url
DATABASE_URL="mongodb://127.0.0.1/messenger-clone"

# client url for next auth
NEXTAUTH_URL=http://localhost:3000

# next auth secret (random strings)
NEXTAUTH_SECRET=<your-nextauth-secret>

# github auth credentials
GITHUB_CLIENT_ID=<your-github-client-id>
GITHUB_CLIENT_SECRET=<your-github-client-secret>

# google auth credentials
GOOGLE_CLIENT_ID=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=<your-google-client-secret>

# next cloudinary credentials
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME=xxxxxxxxx
NEXT_PUBLIC_CLOUDINARY_CLOUD_PRESET=xxxxxxxxxx

# pusher credentials
PUSHER_APP_ID=00000000
PUSHER_APP_SECRET=xxxxxxxxxxxxxxxxxxxxxx
NEXT_PUBLIC_PUSHER_APP_KEY=xxxxxxxxxxxxxxxxxxxxx
NEXT_PUBLIC_PUSHER_APP_CLUSTER=xxx
  1. MongoDB URL

    • Install and run MongoDB locally or use a cloud-based MongoDB service.
    • Replace the placeholder in DATABASE_URL with your actual MongoDB connection string.
  2. NextAuth Configuration

    • Set up NextAuth by following the official documentation: NextAuth.js Documentation
    • Set NEXTAUTH_URL to the base URL of your application.
    • Generate a random string for NEXTAUTH_SECRET.
  3. GitHub Auth

    • Create a GitHub OAuth App by following the guide: Creating an OAuth App
    • Set GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET with the obtained credentials.
  4. Google Auth

    • Create a project on the Google Cloud Console: Google Cloud Console
    • Follow the steps to set up OAuth consent screen and credentials: Create credentials
    • Set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET with the obtained credentials.
  5. Cloudinary

    • Sign up for a Cloudinary account: Cloudinary Sign-up
    • Retrieve your cloud name from the dashboard.
    • Set NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME and NEXT_PUBLIC_CLOUDINARY_CLOUD_PRESET with the obtained credentials.
  6. Pusher

    • Sign up for a Pusher account: Pusher Sign-up
    • Create a new app and obtain the app ID, app secret, app key, and cluster.
    • Set PUSHER_APP_ID, PUSHER_APP_SECRET, NEXT_PUBLIC_PUSHER_APP_KEY, and NEXT_PUBLIC_PUSHER_APP_CLUSTER with the obtained credentials.
  7. Open terminal in root directory. Run npm install or yarn install.

  8. Now app is fully configured πŸ‘ and you can start using this app using npm run dev or yarn dev.

πŸ“š Additional Resources

  • Next.js Documentation: Explore the power of Next.js for building your web applications.

  • NextAuth.js Documentation: Learn more about authentication in Next.js using NextAuth.js.

  • Tailwind CSS Documentation: Dive into the documentation for Tailwind CSS, a utility-first CSS framework used in the project.

  • Pusher Documentation: Explore Pusher for adding real-time functionality to your applications.

  • React Icons Documentation: Find and customize high-quality SVG icons for your React applications.

  • React Select Documentation: Get to know more about React Select, a flexible and customizable select component.

  • React Hook Form Documentation: Learn about React Hook Form for efficient form management in React.

  • Next Cloudinary Documentation: Understand how to integrate Cloudinary for image and video management.

  • Prisma Documentation: Explore Prisma for database access in TypeScript and JavaScript.

  • Axios Documentation: Find information on how to use Axios for making HTTP requests.

  • Zustand Documentation: Learn about Zustand, a small and fast state management library.

  • React Hot Toast Documentation: Understand how to use React Hot Toast for toast notifications in React applications.

  • Headless UI Documentation: Explore Headless UI, a set of completely unstyled UI components.

NOTE: Please make sure to keep your API keys and configuration values secure and do not expose them publicly.

πŸ“· Screenshots:

Modern UI/UX

Realtime Messaging

Create Group Chats

Edit your Profile

βš™οΈ Tech Stack

React JS Next JS Typescript Tailwind CSS Vercel Prisma

πŸ”§ Stats

Stats for Messenger Clone

πŸ™Œ Contribute

You might encounter some bugs while using this app. You are more than welcome to contribute. Just submit changes via pull request and I will review them before merging. Make sure you follow community guidelines.

πŸ’Ž Acknowledgements

Useful resources and dependencies that are used in Messenger Clone.

β˜• Buy Me a Coffee

πŸš€ Follow Me

GitHub followers Twitter YouTube

πŸ“š Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

πŸ“ƒ Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out Next.js deployment documentation for more details.

⭐ Give A Star

You can also give this repository a star to show more people and they can use this repository.

🌟 Star History

Star History Chart

(back to top)

About

A Real-Time Messenger Clone using Next.js 14.

https://appmessenger.vercel.app/

License:MIT License


Languages

Language:TypeScript 99.0%Language:JavaScript 0.6%Language:CSS 0.4%