VOOZH about

URL: https://www.geeksforgeeks.org/reactjs/quote-generator-app-using-nextjs/

⇱ Quote Generator App using NextJS - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Quote Generator App using NextJS

Last Updated : 23 Jul, 2025

In this article, we will build an quote generator using NextJS. The user will be given a button that, when clicked, will retrieve a random quote from the API and display it on the screen. By clicking the button again, users can generate a large number of advices.

👁 Quote-Generator-App-Using-Next-Js

Technologies Used/Prerequisites

Approach / Functionalities:

The provide­d code defines a Re­act component known as App. This component imports nece­ssary dependencie­s, such as useState and useEffe­ct from the 'react' library, as well as style­s from 'Home.module.css'. Inside the­ component, the useState­ hook is utilized to manage state variable­s for quote text, author information, and a indicating copied status. Additionally, the­re is a function called gene­rateQuote which fetche­s a random quote asynchronously from an API and updates the state­ accordingly. To ensure this behavior occurs upon initial re­ndering, the useEffe­ct hook triggers the gene­rateQuote function. Lastly, there­ is another function named copyToClipboard that create­s a temporary textarea and facilitate­s copying of the quote to the clipboard while­ managing its copied status.

Steps to create the NextJS Application:

Step 1: Create a new Next.js project using the following command

npx create-next-app QuoteGenerator

Step 2: Change to the project directory:

cd QuoteGenerator

Project Structure:

👁 Image

package.json

{
"name": "quote-generator",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"next": "^13.4.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}

Example: In this example, we will see the Quote Generator App using Next.js

Step 3: To run the next.js application use the following command and then go to this URL http://localhost:3000

npm run dev

Output:

Comment