Skip to content

JOAO-LEE/google_clone

Repository files navigation

Introduction

Since I already had experience with React.Js projects, I decided to get to know one of it's "meta frameworks", and coincidentally, I got a beginner-friendly course on Udemy by Sahand Gavidel, where he guides through the fundamentals of Next.js with a hands-on approach. The course includes step-by-step instructions for building four clone projects, with one of them replicating the Google interface.

Google main page
See the details
Google web search loading Google image search loading Google web search results Google image searc results

⚠ It's important to state that some functionalities such as "Sign in", "Microphone input" and "Settings" were not implemented for now, since this application focus on its search functionality. However, I intend to implement some other functionalities.

Getting Started

To clone and run this project locally, firstly:

  1. Ensure you have Node.js installed, with a minimum version of 18.x or a later stable release;
  2. Get a free Google Custom Search API key;

    In order to identify your application client, you will:

  1. Get a Context Key;

    You will need to set up a Programming Search Engine. This means you will have to:

  1. Run the application

    In root folder, run the command:

       npm run dev
       # or
       yarn dev
       # or
       pnpm dev
       # or
       bun run dev
     

    Open http://localhost:3000 with your browser to see the result.

  1. Get API key for IP Localization (Optional)

    This clone gets the user IP address using just like Google and its sets the user's country in the footer. By default, it shows "United States".
    Sahand uses the free package of eXTReMe Geolocation. However, somehow it's not possible to create an account with a Gmail or Hotmail address.
    I could get the same result using ipgeolocation.

    • Create an account;
    • Once you've signed up/logged in, click on "Dashboard"
    • Generate your API Key and copy it
    • In your .env file, assign your ipgeolocation API key value to the corresponding environment variable;
      You can still name it however you would like, but since this component is rendered client side, the environment variable requires the NEXT_PUBLIC_ prefix.
              NEXT_PUBLIC_IP_API_KEY = # past you ipgeolocation key here
            

Development

Stack and Language Decision

Moreover, while Sahand instructs the project using JavaScript, I've chose deliberately to implement it using TypeScript. This decision not only eases the development process with enhanced type safety, but also aligns with the rising trend and widespread adoption of TypeScript in the developer community.
Also, it's worth noting that this project was built with Next.js 14, while Sahand utilized its earlier version in the course.

Styles, Icons and Formatting

To style the project, it was employed Tailwind CSS, a CSS framework which provides classes to style HTML elements, contributing to a more efficient development process.
Additionally, for the integration of icons, React Icons was employed—an extensive library featuring a diverse collection of icons to enhance the overall user experience.
In order to achieve the boldened search term in each result description, html-react-parser was employed, once Google search API brings a property called htmlSnippet for this purpose.

See the example below
Google API result showing htmlSnippet property Search term boldened

About

A Google clone made using TypeScript, Next.js 14 and Tailwind CSS.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published