Skip to content

This is a solution to the REST Countries API with color theme switcher challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Notifications You must be signed in to change notification settings

Adelinked/countries-app

Repository files navigation

Frontend Mentor - REST Countries API with color theme switcher solution

This is a solution to the REST Countries API with color theme switcher challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Table of contents

Note: Delete this note and update the table of contents based on what sections you keep.

Overview

The challenge

Users should be able to:

  • See all countries from the API on the homepage
  • Search for a country using an input field
  • Filter countries by region
  • Click on a country to see more detailed information on a separate page
  • Click through to the border countries on the detail page
  • Toggle the color scheme between light and dark mode (optional)

Screenshot

Links

  • Solution URL: here
  • Live Site URL: here

My process

Built with

  • Semantic HTML5 markup
  • CSS custom properties
  • Flexbox
  • Mobile-first workflow
  • TypeScript
  • React - JS library
  • Next.js - React framework
  • Tailwind CSS - For styles

What I learned

i used useSWR to fetch data in the detail page for a selected country, than depending on the result run another fetch request to get its border countries.

useSWR is a React hook for data fetching and caching in client-side applications. It's often used in conjunction with REST APIs to simplify the data fetching process and improve application performance.

With useSWR, you can provide a URL and a function that retrieves data from that URL, and the hook will handle the rest, including caching the data for you. When the data is needed in your component, the hook will return the cached data if it exists, or fetch new data if it doesn't.

Author

About

This is a solution to the REST Countries API with color theme switcher challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Topics

Resources

Stars

Watchers

Forks