Skip to content

Commit 583eb4e

Browse files
authored
Migrate Next.js to Vite (#1397)
Vite is much simpler to use than Next.js and we don't need any of the features Next has that Vite doesn't have. Benefits of moving to Vite are: - Much better performance in dev and prod environments - Much better build times - Actual support for static exports, no vendor lock-in of having to use Vercel - Support for runtime environment variables/loading config from `.env` files - No annoying backwards-incompatible changes on major releases of Next - Better i18n support without having to define getServerSideProps on every page - Better bundle optimization - No opt-out Vercel telemetry Also replaces yarn by pnpm and upgrades mantine to 8.3
1 parent 3f2563b commit 583eb4e

File tree

104 files changed

+6316
-8189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+6316
-8189
lines changed

.github/workflows/frontend.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,20 @@ jobs:
1919
steps:
2020
- uses: actions/checkout@v5
2121

22-
- name: Setup yarn
22+
- name: Enable Corepack
23+
run: corepack enable
24+
25+
- name: Setup pnpm
2326
uses: actions/setup-node@v6
2427
with:
2528
node-version: '22'
26-
cache: 'yarn'
27-
cache-dependency-path: frontend/yarn.lock
29+
cache: 'pnpm'
30+
cache-dependency-path: frontend/pnpm-lock.yaml
2831

2932
- name: Install npm modules
30-
run: yarn
33+
run: pnpm i
3134
working-directory: frontend
3235

3336
- name: Run prettier, lint, jest checks
34-
run: yarn test
37+
run: pnpm test
3538
working-directory: frontend

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ uv.lock
66
.mypy_cache
77
.dmypy.json
88
.pytest_cache
9+
.yarn
910

1011
*.env
1112
!ci.env

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<h1></h1>
5151

5252
Tournament system meant to be easy to use. Bracket is written in async Python (with
53-
[FastAPI](https://fastapi.tiangolo.com)) and [Next.js](https://nextjs.org/) as frontend using the
53+
[FastAPI](https://fastapi.tiangolo.com)) and [Vite](https://vite.dev/) as frontend using the
5454
[Mantine](https://mantine.dev/) library.
5555

5656
It has the following features:
@@ -104,17 +104,17 @@ Read the [configuration docs](https://docs.bracketapp.nl/docs/running-bracket/co
104104
Bracket's backend is configured using `.env` files (`prod.env` for production, `dev.env` for development etc.).
105105
But you can also configure Bracket using environment variables directly, for example by specifying them in the `docker-compose.yml`.
106106

107-
The frontend doesn't can be configured by environment variables as well, as well as `.env` files using Next.js' way of loading environment variables.
107+
The frontend doesn't can be configured by environment variables as well, as well as `.env` files using Vite's way of loading environment variables.
108108

109109
# Running Bracket in production
110110
Read the [deployment docs](https://docs.bracketapp.nl/docs/deployment) for how to deploy Bracket and run it in production.
111111

112-
Bracket can be run in Docker or by itself (using `uv` and `yarn`).
112+
Bracket can be run in Docker or by itself (using `uv` and `pnpm`).
113113

114114
# Development setup
115115
Read the [development docs](https://docs.bracketapp.nl/docs/community/development) for how to run Bracket for development.
116116

117-
Prerequisites are `yarn`, `postgresql` and `uv` to run the frontend, database and backend.
117+
Prerequisites are `pnpm`, `postgresql` and `uv` to run the frontend, database and backend.
118118

119119
# Translations
120120
Based on your browser settings, your language should be automatically detected and loaded. For now,

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ services:
2626
bracket-frontend:
2727
container_name: bracket-frontend
2828
environment:
29-
NEXT_PUBLIC_API_BASE_URL: http://localhost:8400
30-
NEXT_PUBLIC_HCAPTCHA_SITE_KEY: 10000000-ffff-ffff-ffff-000000000001
29+
VITE_API_BASE_URL: http://localhost:8400
30+
VITE_HCAPTCHA_SITE_KEY: 10000000-ffff-ffff-ffff-000000000001
3131
image: ghcr.io/evroon/bracket-frontend
3232
ports:
3333
- 3000:3000

docs/content/community/development.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ two sections.
5656

5757
```bash
5858
cd frontend
59-
yarn run dev
59+
pnpm run dev
6060
```
6161

6262
### Backend

docs/content/deployment/docker.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ services:
2626
- "3000:3000"
2727
environment:
2828
NODE_ENV: "production"
29-
NEXT_PUBLIC_API_BASE_URL: "http://your-site.com:8400"
30-
NEXT_PUBLIC_HCAPTCHA_SITE_KEY: "10000000-ffff-ffff-ffff-000000000001"
29+
VITE_API_BASE_URL: "http://your-site.com:8400"
30+
VITE_HCAPTCHA_SITE_KEY: "10000000-ffff-ffff-ffff-000000000001"
3131
restart: unless-stopped
3232

3333
bracket-backend:
@@ -63,9 +63,9 @@ Replace the lines that are highlighted in the code block from the previous step.
6363
6464
Replace the following values for `bracket-frontend`:
6565

66-
- `NEXT_PUBLIC_API_BASE_URL`: The address of your backend. The frontend will send
66+
- `VITE_API_BASE_URL`: The address of your backend. The frontend will send
6767
requests to this address.
68-
- `NEXT_PUBLIC_HCAPTCHA_SITE_KEY`: Either leave empty to disable it or
68+
- `VITE_HCAPTCHA_SITE_KEY`: Either leave empty to disable it or
6969
[signup for hCaptcha](https://dashboard.hcaptcha.com/signup), create a site and
7070
put the site key here
7171

docs/content/deployment/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ See [the config docs](/docs/running-bracket/configuration.mdx) for more informat
3131

3232
The following configuration variables need to be adjusted for the frontend to run it in production:
3333

34-
- `NEXT_PUBLIC_API_BASE_URL`: The base URL of the backend API to which the frontend sends requests.
34+
- `VITE_API_BASE_URL`: The base URL of the backend API to which the frontend sends requests.
3535
For example: `https://api.bracket.com`
3636

3737
Optional:
3838

39-
- `NEXT_PUBLIC_HCAPTCHA_SITE_KEY`: The HCaptcha key used for captcha challenges when creating new
39+
- `VITE_HCAPTCHA_SITE_KEY`: The HCaptcha key used for captcha challenges when creating new
4040
accounts. You get the secret when you create a new site in HCaptcha. If left blank, HCaptcha will
4141
be disabled for your site.
4242

docs/content/deployment/nomad.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ job "bracket-frontend" {
8989
driver = "docker"
9090
9191
env {
92-
NEXT_PUBLIC_API_BASE_URL = "https://my.bracketdomain.com"
93-
NEXT_PUBLIC_HCAPTCHA_SITE_KEY = "xxxxx"
92+
VITE_API_BASE_URL = "https://my.bracketdomain.com"
93+
VITE_HCAPTCHA_SITE_KEY = "xxxxx"
9494
NODE_ENV = "production"
9595
}
9696
9797
config {
9898
image = "ghcr.io/evroon/bracket-frontend"
9999
ports = ["nextjs"]
100-
args = ["yarn", "start", "-p", "${NOMAD_PORT_nextjs}"]
100+
args = ["pnpm", "start", "-p", "${NOMAD_PORT_nextjs}"]
101101
}
102102
103103
resources {

docs/content/deployment/systemd.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ After=network.target
5151
Type=simple
5252
User=bracket
5353
WorkingDirectory=/var/lib/bracket/frontend
54-
ExecStart=/usr/local/bin/yarn start
54+
ExecStart=/usr/local/bin/pnpm start
5555
Environment=NODE_ENV=production
5656
TimeoutSec=15
5757
Restart=always

docs/content/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: Introduction
55

66
[Bracket](https://github.com/evroon/bracket) is a tournament system meant to be easy to use. Bracket
77
is written in async Python (with [FastAPI](https://fastapi.tiangolo.com)) and
8-
[Next.js](https://nextjs.org/) as frontend using the [Mantine](https://mantine.dev/) library.
8+
[Vite](https://vite.dev/) as frontend using the [Mantine](https://mantine.dev/) library.
99

1010
## Overview of features
1111

@@ -36,7 +36,7 @@ tournament systems that exist usually only support Swiss, no other types of tour
3636
(round-robin, elimination etc.). That is quite a limitation when you want to host a tournament that
3737
starts with Swiss and determines a winner based on a knockoff (elimination) stage.
3838

39-
**Finally**, I developed this project to learn more about Next.js and apply my Python (e.g. FastAPI)
39+
**Finally**, I developed this project to learn more about Vite and apply my Python (e.g. FastAPI)
4040
experience to a project with a real purpose.
4141

4242
## Quickstart

0 commit comments

Comments
 (0)