A simple URL shortener built using Go for the backend and SvelteKit for the frontend that generates shortened URLs and redirects users to the original URLs.
- Shorten long URLs to compact, easy-to-share links.
- Redirect users to the original URL when they visit the shortened link.
- In-memory storage for quick lookups.
- Frontend built with SvelteKit for a seamless user experience.
git clone https://github.com/DineshNehra29/URL-Shortener.git
go run main.goThe server will start at http://localhost:3001.
cd frontend
npm install
npm run devThe frontend will start at http://localhost:5173.
- Open the frontend at
http://localhost:5173. - Enter a URL and click Shorten.
- A shortened link will be generated and displayed.
You can also shorten a URL using a POST request to /shorten:
curl -X POST http://localhost:3001/shorten -H "Content-Type: application/json" -d '{"url": "https://example.com"}'{
"short_url": "http://localhost:3001/redirect/{shortened_id}"
}Click the generated short link or visit:
http://localhost:3001/redirect/{shortened_id}
It will redirect you to https://example.com.
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Root page |
| POST | /shorten |
Shorten a URL |
| GET | /redirect/:id |
Redirect to the original URL |
To make your URL shortener available on the internet:
- Use Ngrok to expose the local server:
ngrok http 3001
- Deploy it to a cloud provider like AWS, DigitalOcean, or Heroku.
- Containerize it using Docker for easy deployment.
Feel free to open issues or submit pull requests to improve the project!