This is a simple currency converter web application built using React, Axios, and the ExchangeRate API. The app allows users to convert an amount from one currency to another in real-time using up-to-date exchange rates.
Check out the live demo here
- Convert currency from one unit to another (USD, EUR, INR, GBP, AUD).
- Real-time exchange rates using the ExchangeRate API.
- Error handling for API failures and invalid inputs.
- Formatted currency display for better readability.
- React: Front-end library for building the user interface.
- Axios: Library for making HTTP requests to fetch exchange rates from the API.
- ExchangeRate API: Provides real-time exchange rates for currency conversion.
- Clone the repository:
git clone [https://github.com/your-username/currency-converter.git](https://github.com/surajgharpankar28/Currency-Converter.git) cd currency-converter
- Install dependencies:
npm install
- Set up the ExchangeRate API:
- To obtain an API key, sign up on ExchangeRate API.
- Create a .env file in the project root and add your API key:
VITE_API_KEY=your_api_key_here
- Add the following to your 'vite.config.js' file.
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
// https://vite.dev/config/
export default defineConfig({
plugins: [
react(),
{
name: "replace-process-env",
// Use the "transform" hook to replace process.env variables
transform(code) {
return code.replace(
/process\.env\.VITE_API_KEY/g,
JSON.stringify(process.env.VITE_API_KEY)
);
},
},
],
});
- Run the application
npm start