How to add a new page to a ViteJS project

Oscar de la Hera Gomez
Two flowers that represent ReactJS and ViteJS, beneath them sits the text "Entry Points."

A step by step guide on adding pages (i.e. multiple entry points) in a ReactJS and ViteJS project.

We recommend that you clone our Open Source React, Typescript & ViteJS Starter Project, checking out the main branch and carrying out the steps below. The changes can be found on the tutorial/entry-points branch.

git clone git@github.com:delasign/reactjs-3js-vitejs-starter-project.git

Step One: Setup the Project

A screenshot of Chrome showing that the plane is now using the shader that we offer in this tutorial.

Follow the tutorial below to learn how to setup a ViteJS project to work with GLSL, ReactJS, Typescript & ThreeJS.

Step Two: Create the page

A screenshot of VSCode showing how we created a new page by copying all the files that represent a page. Highlighted on the index.html is how we changed the route to the main.tsx file and how we changed the meta title.

Copy the index.html, App.css, App.tsx, index.css and main.tsx into a new folder within the source folder.

Make sure that the src of the index.html file to point to the new main.tsx file of the folder. We also strongly suggest that you update the meta title of the page.

Step Three: Create the Entry Point

A screenshot of VSCode showing the vite.config.ts file. Highlighted is how we added "root" to the top of the config as well as how we added the inputs. These are available in our open source repository.

In the vite.config.ts, add the root to the top of the configuration definition.

Beneath it, within the build options, add the rollupOptions which must include the inputs (i.e. entry points).

Each of these inputs is a page (i.e. entry point), where "main" is the "index.html" and the others must match a location of a page that you created within the ViteJS project.

Step Four: Test

A screenshot of Chrome showing a page from a ViteJS project. Highlighted is the meta title and the URL which demonstrate that the changes have taken place.

Run the app and confirm that the entry points work as expected.

Looking to learn more about ReactJS and ViteJS ?

Search our blog to find educational content on learning how to use ReactJS and ViteJS.

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.
delasign logo

Book a Free Consultation.

An icon of an email.

Click here to email us.

Fill in the details below to book a free consultation or to let us know about something else. Whatever it is, we are here to help.

How can we help you ?

Contact Details