vercel-spa
v1.0.0
Published
A simple CLI tool to generate a `vercel.json` file configured for Single Page Application (SPA) routing on Vercel.
Readme
Vercel SPA
A simple CLI tool to generate a vercel.json file configured for Single Page Application (SPA) routing on Vercel.
Installation
Install the package globally to use it from the command line:
npm install -g vercel-spaOr, run it directly using npx:
npx vercel-spaUsage
Navigate to your project directory and run:
vercel-spaThis will create a vercel.json file in your project root with the following content:
{
"rewrites": [
{
"source": "/(.*)",
"destination": "/index.html"
}
]
}This configuration ensures that all routes are redirected to index.html, allowing client-side routing (e.g., React Router) to handle navigation without 404 errors on refresh.
Notes
- If a
vercel.jsonfile already exists, the command will exit with an error to prevent overwriting. Delete or modify the existing file manually if needed. - This package uses the
fs-extralibrary for reliable file operations.
License
MIT
