This website uses cookies to ensure you get the best experience on our website.

Skip to content
LOGO
  • Company

    About IGNEK

    Learn about our story and our mission.

    Careers

    We're hiring!

    We always looking for talented peoples. Join our team!

    Blogs

    The latest industry news, updates and info.

    Case Studies

    Take a closer look at the projects we've delivered

    Webinar

    Watch our latest organized webinar

    Get in touch with our HR team

    • hr@ignek.com
    • +91 93284 95160
    • Ahmedabad, Gujarat, India – 382470
  • Services

    Enterprise Portal Development

    Custom Enterprise Portal Development for flawless Solutions

    Dedicated Development Team

    Expand Teams, Optimize Development with Our Expertise

    Back-end Development

    Empowering your digital presence with robust backend development expertise

    Front-end Development

    Crafting engaging user experiences through expert frontend development

    Digital Transformation

    Embrace digital transformation by modernizing process

    SaaS Development

    Transform your business with SaaS Innovative Solutions

    Technologies

    Liferay Services

    Development & Customization

    Theme

    Upgradation

    Migration

    Proof of Concept

    Performance Tunning

    Architecture

    Support & Maintenance

    E-commerce

    Expert Advice

    React Services

    Enterprise Development

    Custom Application

    Single Page Application

    Architecture

    API Integration

    Migration

    Consulting

    Maintenance & Support

    Spring Boot Services

    Web Service

    MVC Web Development

    API Integration

    Security

    Migration

    Microservices

    Support & Maintenance

    AEM Services

    Consulting Service

    Site Development

    Migration & Upgradation

    Integration

    Maintenance & Support

    Custom Solutions

    Content Management

    Team Augementation

  • Solution

    Ready for digital excellence

    In our rapidly evolving world, businesses are always on the lookout for fresh ways to improve their operations and connect with their audiences.

    Contact US

    Solutions

    SaaS : Software As A Service

    Transforming industries through cutting edge SaaS solutions.

    Customer Portal : Boost Business Productivity

    Streamline operations and enhance productivity with our Customer Portal solution.

    Liferay Based Intranet Portal

    Internal portal for company communication, collaboration and resources

    Integration

    Matomo Integration with Liferay

    Integrate Matomo to enable user interactions seamlessly.

    Microsoft Teams integration with Liferay

    Integrate to enable seamless collaboration, messaging within your portal.

    Jira Integration With Liferay

    Optimizes business operations by integrating with Jira.

  • Hire Us

    Liferay

    Get expert Liferay developers for seamless portal solutions.

    React JS

    Get expert ReactJS developers for dynamic web solutions.

    Web Developer

    Get custom web solutions from IGNEK's expert developers.

    Spring Boot

    Get top-notch Spring Boot developers for your project success!

    Healthcare

    Get top Healthcare Developers for cutting-edge medical software.

    MERN Stack

    Get expert MERN developers from IGNEK for custom, innovative project solutions.

    Why Hire Developers From IGNEK ?

    • Certified Developer
    • Transparent Communication
    • Flexible Hiring Modals
    • Fully Signed NDA
    • Cost Effective
    • Easy Exit Policy

    Get in touch with our Sales team

    • sales@ignek.com
    • +91 6351576580
    • info@ignek.com
    • Ahmedabad, Gujarat, India – 382470
SCHEDULE CALL
  • COMPANY
    • About
    • Case Studies
    • Blogs
    • Career
    • Webinar
  • SERVICES
    • Enterprise Portal Development
    • Dedicated Development Team
    • Back-end Development
    • Front-end Development
    • Digital Transformation
    • SaaS Development
  • SOLUTION
    • Customer Portal:  Boost Business Productivity
    • SaaS : Software as a Service
    • Liferay Based Employee Intranet Portal
  • TECHNOLOGY
    • Liferay Services
      • Liferay Development and Customization
      • Liferay Theme Development Service
      • Liferay DXP 7.4 Upgrade
      • Liferay Migration
      • Liferay Proof Of Concept
      • Liferay Performance Tuning
      • Liferay Architecture Design Service
      • Liferay Support And Maintenance Service
      • Liferay Ecommerce Development
      • Liferay Expert Advice
    • ReactJS Services
      • ReactJS Enterprise Application Development
      • ReactJS Custom Application Development
      • ReactJS Single Page Application Development (SPA)
      • ReactJS Applications Architecture
      • ReactJS API Integration
      • ReactJS Migration
      • ReactJS Consulting
      • ReactJS Maintenance and Support
    • Spring Boot Services
      • Spring Boot Web Development Service
      • Spring MVC Web Development
      • Spring Boot API Integration Service
      • Spring Boot Security
      • Spring Boot Migration Service
      • Spring Boot Microservices
      • Spring Boot Support & Maintenance Service
    • AEM Development Services
      • AEM Consulting Services
      • AEM Site Development
      • AEM Migration & Upgradation
      • AEM Integration Services
      • AEM Maintenance & Support
      • AEM Content Management
      • Custom AEM Solutions
      • AEM Team Augmentation
  • INTEGRATION
  • HIRE US
    • Hire Liferay Developer
    • Hire ReactJS Developer
    • Hire Spring Boot Developer
    • Hire Healthcare Developer
    • Hire Web Developer
    • Hire MERN Stack Developer
  • CONTACT US
  • Company

    About IGNEK

    Careers

    We're hiring!

    Blogs

    Case Studies

    Webinar

    Get in touch with our HR team

    • hr@ignek.com
    • +91 93284 95160
    • Ahmedabad, Gujarat, India – 382470
  • Services

    Enterprise Portal Development

    Dedicated Development Team

    Back-end Development

    Front-end Development

    Digital Transformation

    SaaS Development

    Technologies

    Liferay Liferay Services
    • Development & Customization
    • Theme
    • Upgradation
    • Migration
    • Proof of Concept
    • Performance Tuning
    • Architecture
    • Support & Maintenance
    • E-commerce
    • Expert Advice
    React React Services
    • Enterprise Development
    • Custom Application
    • Single Page Application
    • Architecture
    • API Integration
    • Migration
    • Consulting
    • Maintenance & Support
    Spring Boot Spring Boot Services
    • Web Service
    • MVC Web Development
    • API Integration
    • Security
    • Migration
    • Microservices
    • Support & Maintenance
    AEM AEM Services
    • Consulting Service
    • Site Development
    • Migration & Upgradation
    • Integration
    • Maintenance & Support
    • Custom Solutions
    • Content Management
    • Team Augmentation
  • Solution

    Ready for digital excellence

    In our rapidly evolving world, businesses are always on the lookout for fresh ways to improve their operations and connect with their audiences.

    Contact US

    Solutions

    SaaS : Software As A Service

    Customer Portal : Boost Business Productivity

    Liferay Based Intranet Portal

    Integration

    Matomo Integration with Liferay

    Microsoft Teams integration with Liferay

    Jira Integration With Liferay

  • Hire Us

    Liferay

    React JS

    Web Developer

    Spring Boot

    Healthcare

    MERN Stack

    Why Hire Developers From IGNEK ?

    • Certified Developer
    • Transparent Communication
    • Flexible Hiring Modals
    • Fully Signed NDA
    • Cost Effective
    • Easy Exit Policy

    Get in touch with our Sales team

    • sales@ignek.com
    • +91 6351576580
    • IGNEK
    • Ahmedabad, Gujarat, India – 382470
  • SCHEDULE CALL

QR code generator app

  • ReactJS
  • March 7, 2025

Share On :

Introduction

Adding QR code generation and download features to a React.js app makes sharing information easy. QR codes can store data like website links, text, and images. They were first used for product labeling and inventory tracking but are now common in daily life. You can find them in UPI payments, WhatsApp contact sharing, and Play Store app links.

In this blog, we’ll show you how to generate and download QR codes in a React.js app. This will let users create, save, share, or print their own QR codes with ease.

Prerequisites
  • Node.js and npm
  • React
  • MUI 
  • MUI Icons
  • Qrcode
  • react-color
Use Cases of Custom QR Codes in Your React App
  • Product Information : Generate QR codes that link to product details like pricing and reviews.
  • Event Ticketing : Use QR codes for concert, flight, or conference tickets, allowing quick access for event entry.
  • Contact Information : Share contact details easily through QR codes.
  • App Downloads : Direct users to your app’s store page via QR codes for simple installation.
  • Wi-Fi Sharing : Share Wi-Fi credentials with a scannable QR code for easy connection.
  • Payment Links : Generate QR codes for payment links via UPI or PayPal.
  • Dynamic QR Codes for Marketing : Use QR codes to track marketing campaigns, offering promotions or discounts.

We’ll show you how to generate and customize QR codes in React.js to enhance your app’s functionality.

Start the React App

If you don’t have a React project yet, you can make one like this:

				
					//Create react app using the following command
npx create-react-app qrcode_generator

//Install the required library
npm i @mui/material @emotion/react @emotion/styled @mui/icons-material
npm i qrcode
npm i react-color

				
			

About qrcode Library

The qrcode library is a versatile tool for generating QR codes in React. It supports customization, allowing you to create scannable codes for URLs, text, and more. With options for data types, sizes, and error correction, it simplifies adding QR functionality to your app.

In our React project, App.js serves as the main entry point. It manages state, processes user actions, and renders core components. Below is the code for App.js:

				
					//Necessary Imports

function App() {
  const [qrData, setQrData] = useState({ link: "", fgColor: "#000000", bgColor: "#ffffff" });

  const handleQRCodeGenerate = (link, fgColor, bgColor) => {
    setQrData({ link, fgColor, bgColor });
  };

  return (
    <Box>
                <QRConfiguration onQRCodeGenerate={handleQRCodeGenerate} />
                <GenerateQR
                    link={qrData.link}
                    fgColor={qrData.fgColor}
                    bgColor={qrData.bgColor}
               />
    </Box>
  );
}

export default App;


				
			

In this code, the App.js component manages the QR code generation functionality by using React state and passing data between two child components.

Functionality

  • State Management :
      • The GenerateQR component receives the latest qrData (link, foreground color, and background color) from the state. It is responsible for generating and displaying the QR code based on these values.
      • The main idea is that QRConfiguration captures user input, and GenerateQR updates the QR code dynamically as the state changes.
  • handleQRCodeGenerate Function :
      • This function is passed down as a prop to the QRConfiguration component.
      • When the QRConfiguration component triggers the QR code generation, this function updates the qrData state with the new values for link, fgColor, and bgColor.
  • Rendering the QR Code :
      • The GenerateQR component receives the latest qrData (link, foreground color, and background color) from the state. It generates and displays the QR code based on these values.

The main function is to capture user input in QRConfiguration and update the QR code in GenerateQR dynamically as the state changes

				
					
//Necessary Imports

function QRConfiguration({ onQRCodeGenerate }) {
  const [link, setLink] = useState("");
  const [fgColor, setFgColor] = useState("#000000");
  const [bgColor, setBgColor] = useState("#ffffff");
  const [showColorPicker, setShowColorPicker] = useState(false);

  const handleCreateQRCode = () => {
    onQRCodeGenerate(link, fgColor, bgColor);
  };

  const handleColorChange = (color, type) => {
    if (type === "fgColor") {
      setFgColor(color.hex);
    } else if (type === "bgColor") {
      setBgColor(color.hex);
    }
  };

  return (
    <Container>
      <Typography>
        Generate Your Custom QR Code
      </Typography>

      <TextField
        label="Enter URL"
        value={link}
        onChange={(e) => setLink(e.target.value)}
      />
      <Box>
        <Button
          onClick={() => setShowColorPicker(!showColorPicker)}
         >
          {showColorPicker ? "Close Color Pickers" : "Customize Colors"}
        </Button>

        {showColorPicker && (
          <Box>
                <Typography>
                  Pick QR Code Foreground Color:
                </Typography>
                <ChromePicker
                  color={fgColor}
                  onChange={(color) => handleColorChange(color, "fgColor")}
                />
                <Typography>
                  Pick QR Code Background Color:
                </Typography>
                <ChromePicker
                  color={bgColor}
                  onChange={(color) => handleColorChange(color, "bgColor")}
                />
          </Box>
        )}

        <Button
          onClick={handleCreateQRCode}
          disabled={!link}
        >
          Generate QR Code
        </Button>
      </Box>
    </Container>
  );
}

export default QRConfiguration;


				
			

The QRConfiguration component lets users customize their QR code by entering a URL and choosing foreground and background colors. It stores these values in the state. When the “Generate QR Code” button is clicked, it calls onQRCodeGenerate with the selected details. The button stays disabled until a valid URL is entered.

				
					
//Necessary Imports

function GenerateQR({ link, fgColor, bgColor }) {
  const [isGenerating, setIsGenerating] = useState(true);
  const [qrCodeDataUrl, setQrCodeDataUrl] = useState("");

  useEffect(() => {
    if (link) {
      setIsGenerating(true);
      QRCode.toDataURL(link, { color: { dark: fgColor, light: bgColor } })
        .then((url) => {
          setQrCodeDataUrl(url);
          setIsGenerating(false);
        })
        .catch((err) => {
          console.error(err);
          setIsGenerating(false);
        });
    }
  }, [link, fgColor, bgColor]);

  const handleDownload = () => {
    if (qrCodeDataUrl) {
      const link = document.createElement("a");
      link.href = qrCodeDataUrl;
      link.download = "qrcode.png";
      link.click();
    }
  };

  return (
    <Box>
      {isGenerating ? (
        <QrCode2RoundedIcon/>
      ) : (
        <>
          <img src={qrCodeDataUrl} alt="QR Code" />
        </>
      )}
      <Button onClick={handleDownload} disabled={isGenerating}>
        Download QR Code
      </Button>
    </Box>
  );
}

export default GenerateQR;


				
			
Output
output-1
output-2
output-3
Conclusion

In conclusion, this React app allows users to easily generate custom QR codes by inputting a URL and selecting foreground and background colors. The app efficiently manages state and dynamically updates the QR code based on user preferences.

Explore Our Services

Discover how we can help your business thrive, whether you’re running a small startup, an SME, or a large enterprise. We’re here to understand your unique needs and goals, offering the expertise and resources to support your journey to success.
Stay informed about our ReactJS services and updates by subscribing to our newsletter—just fill in the details below to subscribe.

Loading
Loading...

Related Blogs

March 27, 2024
Authentication and Authorization in React
September 20, 2024
Building Multi-Step Forms in React
Building Multi-Step Forms in React
January 7, 2025
API headers demystified a guide for React JS developers
API headers demystified : a guide for React JS developers
Loading...

Featured Projects Portfolios

October 3, 2023
HIPAA-Compliant Patient Portal with FHIR Interoperability
HIPAA-Compliant Patient Portal with FHIR Interoperability
March 21, 2024
EPF Government Enterprise Website _ Multilingual, Access for Member, Employer, Corporate - New
EPF Government Enterprise Website : Multilingual, Access for Member, Employer, Corporate
June 19, 2024
Music License Management Portal _ Onboarding & Data Integrity
Music License Management Portal : Onboarding & Data Integrity

Digital Solutions for Your Business with IGNEK

4.9

5.0

5.0

5.0

LOGO

Making the world a better place through constructing elegant hierarchies

COMPANY

  • About
  • Career
  • Case Study
  • Blogs

SERVICES

  • Enterprise Portal Development
  • Dedicated Development Team
  • Back-end Development
  • Front-end Development
  • Digital Transformation
  • SaaS Development

HIRE US

  • Liferay
  • Spring Boot
  • ReactJS
  • Healthcare
  • MERN Stack
  • AEM

CONTACT

  • info@ignek.com
  • info@ignek.com
SALES
  • sales@ignek.com
  • (+91) 635 157 6580
CAREER
  • hr@ignek.com
  • (+91) 932 849 5160
  • E 910-912, Ganesh Glory 11, Jagatpur Road, SG Highway, Ahmedabad, Gujarat - 382470

© 2018-2025 IGNEK, Inc. All rights reserved

Linkedin Facebook X-twitter Instagram