A simple React application that redirects users to social media profiles using custom routes and query parameters. Perfect for creating short, memorable links to your social profiles that you can share easily.
- Direct routing with path parameters (e.g.,
/#/github) - Query parameter redirects (e.g.,
/#/join?social=instagram) - Configurable social media profile links
- Fallback UI for failed redirects
- GitHub Pages compatible (using HashRouter)
- Informative home page showing all available redirects
- GitHub:
/#/github - Twitter:
/#/twitter - LinkedIn:
/#/linkedin - Discord:
/#/discord - Dev.to:
/#/devto - More can be easily added!
Access the demo site and try it out: https://harshyadav152.github.io/how
-
Clone this repository or create a new one:
# Option 1: Clone this repo git clone https://github.com/HarshYadav152/social.git cd social-redirect # Option 2: Create from scratch npm create vite@latest my-social-redirect -- --template react cd my-social-redirect npm install react-router-dom
-
Install dependencies:
npm install
-
Configure for GitHub Pages deployment:
npm install --save-dev gh-pages
-
Update your package.json with:
{ "homepage": "https://yourusername.github.io/social-redirect", "scripts": { // other scripts... "predeploy": "npm run build", "deploy": "gh-pages -d dist" } } -
Create a vite.config.js or update existing one:
import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' export default defineConfig({ plugins: [react()], base: './', // Important for GitHub Pages deployment })
-
Open
src/Redirector.jsxand modify the USERNAME variables to your handles:// Your usernames for different platforms const USERNAME1 = "Username1"; const USERNAME2 = "Username2"; // Configure social profile URLs const socialProfiles = { github: `https://github.com/${USERNAME1}`, twitter: `https://twitter.com/${USERNAME2}`, linkedin: `https://linkedin.com/in/${USERNAME1}`, discord: `https://discord.gg/${USERNAME1}`, devto: `https://dev.to/${USERNAME1}`, // Add more platforms as needed };
-
To add more platforms, update both the
socialProfilesobject inRedirector.jsxand add new routes inApp.jsx:// In App.jsx <Route path="/newplatform" element={<Redirector platform="newplatform" />} />
-
Push your code to GitHub:
git add . git commit -m "Setup social media redirector" git push
-
Deploy to GitHub Pages:
npm run deploy
-
Configure GitHub Pages:
- Go to your repository settings
- Navigate to Pages section
- Select the
gh-pagesbranch - Save the changes
Your redirector will be available at https://yourusername.github.io/social-redirect
Access the application and append the social media platform as a hash route:
https://yourusername.github.io/social-redirect/#/github
https://yourusername.github.io/social-redirect/#/twitter
Or use the query parameter approach:
https://yourusername.github.io/social-redirect/#/join?social=github
Start the development server:
npm run devBuild for production:
npm run buildPreview production build:
npm run preview- React 19
- React Router 7
- Vite 7
Contributions are welcome! Please check out our Contributing Guidelines to get started.
- Add support for more social platforms
- Improve UI/UX
- Fix bugs
- Add features from our Roadmap
- Improve documentation
- Report issues
Please make sure to follow our Code of Conduct.
MIT LICENCE
Created with β€οΈ by Harsh Yadav.
Also check some great stuff from my side resources