Giter Site home page Giter Site logo

nextjs-13.5-todo's Introduction

README.md

Next App Auth

A simple Next.js application to demonstrate an authentication flow using JWT (JSON Web Tokens).

Table of Contents

Getting Started

  1. Clone the repository:
git clone [repository-url]
cd next-app-auth
  1. Install the dependencies:
npm install
  1. Start the development server:
npm run dev

Your application should now be running on http://localhost:3000.

Project Structure

  • pages/ - This directory contains all the pages of your Next.js application.

    • api/ - API routes are located here. We've got the login API route that checks the credentials and returns a JWT.
    • dashboard.js - Represents the dashboard page which is shown to the user once they're authenticated.
    • login.js - Contains the login form.
    • index.js (or page.js) - Home page that redirects users based on their authentication status.
  • package.json - Lists the project dependencies and contains scripts for development, build, and test.

Authentication Flow

  1. The user navigates to the login page and enters their credentials.
  2. Upon clicking the login button, a request is sent to the /api/login route.
  3. This route checks the credentials and, if valid, returns a JWT.
  4. This token is then saved to local storage and used to determine if the user is authenticated throughout the app.
  5. If the user navigates to the dashboard, their authentication status is checked using the presence of the JWT in local storage.
  6. A logout button on the dashboard allows the user to remove their token from local storage and be redirected to the login page.

Dependencies

  • next - The React framework for building the application.
  • jsonwebtoken - Used for generating and verifying JWTs.
  • react, react-dom - React library.
  • Dev dependencies include various tools and libraries to help with styling, testing, and transpilation.

Scripts

  • dev: Runs the development server.
  • build: Builds the production version of the app.
  • start: Starts the production server.
  • lint: Lints the codebase using Next.js lint.
  • test: Runs tests using Jest.

For more information, feel free to navigate through the codebase or reach out to the project maintainer.


That's a basic README that covers the main points of your project. You can expand upon it further, adding sections as you deem necessary (e.g., code conventions, how to contribute, future enhancements, etc.).

nextjs-13.5-todo's People

Contributors

babarali581 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.