A modern and streamlined template for building high-performance web applications using React, TypeScript, and Vite, with Vercel serverless functions seamlessly integrated. Ready for rapid development and deployment on Vercel! π
Get started with these simple steps:
git clone [email protected]:Charmingdc/vite-react-ts-vercel-template.git
cd vite-react-ts-vercel-templatenpm install # or yarn install, pnpm installFor local development, start the Vercel serverless function:
vercel dev --listen 3000npm run dev # or yarn dev, pnpm devThis will launch the app at http://localhost:5173.
Alternatively, you can use the Vercel CLI to handle both frontend and serverless functions (Note: Memory-intensive!):
vercel devThis template is built for ease of use and extension. Below are key usage examples:
This template includes a pre-configured /api endpoint for Vercel serverless functions.
// src/App.tsx
import { useState, useEffect } from "react";
function App() {
const [message, setMessage] = useState("");
useEffect(() => {
fetch("/api/handler")
.then((res) => res.json())
.then((data) => setMessage(data.message));
}, []);
return (
<div>
<p>{message}</p>
</div>
);
}
export default App;// api/handler.ts
import { VercelRequest, VercelResponse } from "@vercel/node";
const handler = (req: VercelRequest, res: VercelResponse) => {
res.status(200).json({ message: "Hello from Vercel!" });
};
export default handler;Customize the vite.config.ts file as needed.
// vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [react()],
server: {
proxy: {
'/api': {
target: 'http://localhost:3000',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '/api'),
},
},
},
});β
React 19 β Build modern UI components with React.
β
TypeScript β Strongly-typed JavaScript for better code quality.
β
Vite β Lightning-fast development server and bundler.
β
Vercel β Seamless cloud deployment with built-in serverless functions.
β
ESLint β Keep your code clean and maintainable.
β
Example API Endpoint β Ready-to-use serverless function.
| Technology | Description | Link |
|---|---|---|
| React | Library for building UI components | reactjs.org |
| TypeScript | Typed superset of JavaScript | typescriptlang.org |
| Vite | Fast frontend build tool | vitejs.dev |
| Vercel | Cloud platform for static & serverless apps | vercel.com |
| ESLint | JavaScript linter | eslint.org |
Contributions are welcome! π Hereβs how you can contribute:
- π Report Bugs β Open issues with clear steps to reproduce.
- π‘ Suggest Features β Propose new ideas for improvement.
- π οΈ Submit Pull Requests β Enhance the project with code contributions.
This project is licensed under the MIT License.
- Author: Charmingdc
- GitHub: Charmingdc
- X (Twitter): Charmingdc01