Use your custom 404 component on Vercel — Easy Fix

●2 ●5 ●14
calendar_today • schedule1 min read
— Originally published at medium.com


I had just deployed a React application to Vercel, complete with routing and a custom 404 error page. I tested the live site in Vercel and tried visiting a non-existent route, but I couldn’t! Vercel’s default 404 page was rendered instead of my custom component.

Here’s how I fixed it

I needed to find a way to overwrite the default action by Vercel, so I conducted some research. So here’s what was happening - Vercel served its own 404 page before my React app loaded.

To fix this, first create a vercel.json file. Use the following code snippet in your file.

{
  "rewrites": [
    { "source": "/(.*)", "destination": "/" }
  ]
}

That was it! I redeployed the application, and now my 404 component was rendered instead of the default one from Vercel.

I hope this solution helped you. If so, please leave a comment below.

Thanks for reading, ciao

P.S. If your cursor starts acting up in VS Code, check out this article

Want more #software-engineering & #react deep dives?

Join 6,147+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

2 Comments

0 votes
0 votes

More Posts

Local-First: The Browser as the Vault

Pocket Portfolio - Apr 20

How I Built a React Portfolio in 7 Days That Landed ₹1.2L in Freelance Work

Dharanidharan - Feb 9

The Esoteric Realms of Code

nevmenandr - Nov 14

How to Deploy Your Website for Free (Vercel, Netlify, GitHub Pages)

muhammadfarhan.dev - Aug 14

Your AI Agent Doesn't Need Your Token: Edera's Ariadne Conill on Object Capabilities

Tom Smithverified - Nov 5
chevron_left
745 Points • 21 Badges
Lagos, Nigeria • linktr.ee/goldenekpendu
3Posts
4Comments
Frontend Developer | Graphic Designer | Occasional writer

Related Jobs

Commenters (This Week)

1 comment
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!