This is an example of how to set up a React application or static site with Vite to deploy on Kinsta’s Application or Static Site Hosting services from a GitHub repository.
Vite is a tool that helps you build decentralized applications; it provides developer tools and APIs to simplify the development process and supports multiple programming languages. More information can be found on the Vite website.
React is a popular JavaScript library for building user interfaces. It allows developers to create reusable UI components and efficiently update the UI in response to data changes. More information is available on the React website.
Kinsta automatically installs dependencies defined in your package.json file during the deployment process.
Static Site Hosting
- Log in to GitHub and create a new repository from this template (Use this template > Create a new repository): Kinsta – Hello World – Vite + React.
- In MyKinsta, add a static site with the Hello World – Vite + React repository and the following Build settings:
- Build command:
npm run build
- Node version: 18.16.0
- Publish directory: dist
- Build command:
- The site is available as soon as the build finishes, and the Kinsta Welcome page loads at your site’s URL.
Application Hosting
- Log in to GitHub and create a new repository from this template (Use this template > Create a new repository): Kinsta – Hello World – Vite + React.
- In MyKinsta, add an application with the Hello World – Vite + React repository. The Start command can be left blank for the web process as Kinsta automatically detects the required command during the first deployment.
- The app is available as soon as the build finishes, and the Kinsta Welcome page loads at your application’s URL.
Web Server Setup
Port
Kinsta automatically sets the PORT
environment variable. You should not define it yourself, and you should not hard-code it into the application.
Start Command
Kinsta automatically creates a web process based on the npm start
command in the package.json file when deploying an application.
Deployment Lifecycle
Whenever a deployment is initiated (through creating an application or redeploying due to an incoming commit), the npm install
and npm build
commands are run.
Welcome Page
The app or site is available as soon as the build finishes, and the Kinsta Welcome page loads at your application’s URL or static site’s URL.
