Demo, all content is generated
Question

My app works on localhost, how do I actually put it on the internet?

Solved · 2603 views · asked by gabriel_ss · edited

Sorry if this is a dumb question. I built a React app with Lovable, exported it, and now I run it with npm run dev and it works on localhost:5173. My friend wants to try it from her phone. I don't understand what "deploy" means in practice. Do I need a server? Do I pay for something?

What I’ve tried

Sent my friend the localhost link, which obviously didn't work. Read the Vite docs page about deploying but it assumes I know what a static host is.

Comment
Bookmarking this to send to people. The 'localhost means this computer' line is the best explanation I've seen. postgres_pete · edited

3 answers

Marked as helpful by the asker
wes_codes · edited

Not dumb at all. localhost means "this computer", so only you can open it.

Your app is a static site: npm run build turns it into plain HTML/JS/CSS files in a dist folder. Hosting means putting those files on a computer that's always online. Your data lives in Supabase, which is already online.

Easiest path, free:

  1. Put the code on GitHub.
  2. Sign up at Vercel or Netlify with your GitHub account, click "Import project", pick the repo.
  3. It detects Vite automatically. Click Deploy.
  4. You get a URL like your-app.vercel.app. Send that to your friend.

After that, every push to GitHub updates the site automatically. You only pay later if you get a lot of traffic or want team features.

Comment
It's live!! My friend is using it on her phone right now. I can't believe it was 4 steps. gabriel_ss · edited
One thing: login redirects to localhost after she signs in? gabriel_ss · edited
Supabase → Authentication → URL Configuration: set Site URL to your vercel.app URL and add it to Redirect URLs. Supabase still thinks your app lives on localhost. mira_dev · edited
postgres_pete · edited

One addition: your Supabase anon key is now visible to anyone who opens the site (that's normal and by design). What protects your data is Row Level Security. Before sharing the link more widely, check that every table has RLS enabled with policies, the Supabase dashboard warns you about tables without it.

Comment
Checked, two tables had RLS off. Fixed before sharing further. Thanks! gabriel_ss · edited
sam_builds · edited

Late to this, but I was in the exact same spot. One more thing that tripped me: environment variables. If your app uses a .env file locally, add the same variables in Vercel's project settings, the .env file isn't uploaded (and shouldn't be).

Comment
Mine didn't have any but good to know, thanks gabriel_ss · edited