This is a GitHub template project to set up a React app with TypeScript running on Deno. It uses Vite as the dev server and an oak http server on the backend to serve the built project.
- React with TypeScript on the frontend
- Vite for the development server
- Deno for server-side JavaScript/TypeScript
- Oak framework for building web applications
- Static file serving
- Router setup
To run this app, you will need to have Deno installed.
- Create a new repository using this template. From the repository page, click the "Use this template" button in the top right hand of the page:
-
Use the Owner dropdown menu to select the account you want to own the repository and set the repository name and visibility.
-
Clone the repository created to your local machine.
git clone https://github.com/your-username/your-repo-name.git
cd your-repo-name
For a step by step guide to using a GitHub template follow this walkthrough
To install the dependencies for the frontend and backend, run the following command:
deno install
The app uses a Vite dev server to run in development mode. To start the dev server, run the following command:
deno run dev
To build the app for production, run the following command:
deno run build
The backend server uses Deno and the Oak framework to serve the built React app. To start the backend server, run the following command:
deno run serve
To run the tests, use the following command:
deno test -A
.
├── client
│ ├── dist
│ ├── public
│ └── src
│ ├── App.tsx
│ └── main.tsx
└── server
├── main.ts
├── main_test.ts
└── util
└── routeStaticFilesFrom.ts
App.tsx
: The main React componentmain.tsx
: The entry point for the React appmain.ts
: The entry point for the Deno servermain_test.ts
: The test file for the Deno serverrouteStaticFilesFrom.ts
: A utility function to serve static filesdist
: The output directory for the built React apppublic
: The public directory for the React app
The React app is contained in the client
directory. This is also where Vite
will install its dependencies and build the app.
There is a vite.config.ts
file in the root of the project that configures Vite
to build the app in the client/dist
directory and serve the app on port 3000.
The deno.json
file contains the tasks to run the dev server, build the app,
and serve the app, along with the dependencies and the compiler configuration
required to use JSX and React.
The Deno server is contained in the server
directory. The server serves the
built React app from the client/dist
directory and listens on port 8000. This
is what should be used in production.
You can deploy the app with Deno Deploy.
- Link your github account
- Select the repository
- Give the project a name
- Set the "Build Step" to
deno task build
- Set the entry point to
./server/main.ts
- Click 'deploy project'
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License.