This url shortener application is a production ready app, it is a fullstack app powered by Sveltekit and Supabase. It has a robust authentication system, each page / api route is fully protected. It has a good-looking user interface and fully functional CRUD backend operations. Once user sign in the page redirects to dashboard where we can enter original url in the input box to get the shortened url, it is customized to the authenticated user so we won't be able to see the data that does not belong to us.
QuickShort supports 4 languages, they are
English,
Japanese,
Simplified Chinese,
Traditional Chinese
We are gonna use Daisy UI
built-in themes to quickly create this functiona
Daisy UI
has 29 beautiful and prebuilt themes, and they are
"light", "dark", "cupcake", "bumblebee", "emerald", "corporate", "synthwave", "retro", "cyberpunk", "valentine", "halloween", "garden", "forest", "aqua", "lofi", "pastel", "fantasy", "wireframe", "black", "luxury", "dracula", "cmyk", "autumn", "business", "acid", "lemonade", "night", "coffee", "winter"
Each theme contains 9 colors in terms of class name, and they are
"primary", "secondary", "accent", "neutral", "base-100", "info", "success", "warning", "error"
Let us take a look at an exmaple, suppose we want to change color of backround, navbar, btn when we switch theme, I want background of the page to be base-100
, navbar to be neutral
and button to be primary
,
<div id="container" class="bg-base-100">
<div id="navbar" class="bg-neutral">
<button class="bg-primary">Action</button>
</div>
</body>
Once we switch theme the color will be adjusted to corresponging color based upon class name (base-100, neutral, primary), etc.
We also have to add a data-theme=<theme>
attribute within <html>
tag in app.html
, i.e.
app.html
--------
<html lang="en" data-theme="dark">
...
then in our component we can apply a <select>
and <option>
element to select theme to change color of text, background, button, etc.
In order to make our web app running offline, we have to make it a progressive, this requires a manifest.json
and service-worker.js
file to make it work
Create a manifest.json
file
manifest.json
and corresponding icon filesCreate a service worker
file
This app allows authenticated use to create 10 short links, meaning user with free tier has at most ten records in the database, if the number is exceeded user will be redirect to checkout page to proceed the payment, if user doesn't want to pay, then all he/she has to do is to maintain the number of link in dashboard within 10 by removing the unwanted item.
Stripe is the chose payment tech because it is widely adopted and is secure.
if a native app is preferred, user can download the app in the form of Android App from Play Store.
How to turn a web app into an Android app
Download this repo and open it with VSCode
Open terminal and install all the dependencies with the command
npm i
Create an .env
file in root directory and add the following codes
PUBLIC_SUPABASE_ANON_KEY = Your supabaseKey
PUBLIC_SUPABASE_URL = Your supabaseUrl
Create a Supabase account
Create two tables, 'links' and 'clicks'
Create the following column in links table
long_url,
short_key,
count,
created_at,
user
Create the following column in clicks table
ip
link_id
location
user_agent
Run development server
npm run dev