Make sure you have Bun installed on your machine. If you don't have it, you can download it here. Here is some information about Bun in Next.js: Build an app with Next.js and Bun.
If you can't install Bun, you can always use Node.js with the npm
command instead, but it will not be as fast as Bun.
First, install dependencies:
bun install
Also, setup environment variables by copying the .env.example
file to .env
and fill in the values. .env
files are used to store sensitive information like API keys and database credentials and it will not be committed to the repository.
Then, run the development server:
bun dev
Open http://localhost:3000 with your browser to see the result.
When you build the project, you pre-render all the Server Side Generated (SSG) pages. This makes the site load faster and perform better and behave like it will when it is deployed. When serving the built project it will not hot reload when you make changes to the code like it does in development mode.
You can build the project with the following command:
bun run build
To serve the build locally, run:
bun run start
To check linting and formatting you run the respective command:
bun lint
If you are using vscode and are experiencing issues with types, you can restart the typescript server by pressing cmd + shift + p
and then type TypeScript: Restart TS Server
(You need to have a typescript file open for this to work).
You can also try restarting the whole editor by pressing cmd + shift + p
and then type Developer: Reload Window
.
On windows you can use ctrl
instead of cmd
.
We are using Conventional Commits for our commit messages. This is to ensure that we have a consistent way of writing commit messages to make it easier to understand what has been changed and why. Try to follow the guidelines as closely as possible. You can also use the recommended vscode extension to help you write the commit messages.
- To keep the code as consistent as possible use functions for react components or hooks instead of const variables with arrow function syntax. An exception is when using the forwardRef hook or when creating compound components.
- Only use default export for pages or layouts etc. since it is required by Next.js. For everything else use named exports. This is to make it easier to find the components in the codebase or change them without ending up with different names for the same component.
- Use
type
instead ofinterface
for typescript types. This is to keep the code consistent and to make it easier to read. Alsotype
is more flexible thaninterface
since it can be used for unions and intersections.
- All layout components should end with Layout. For example:
DefaultLayout
. - All page components should end with Page to make it clear it is a whole page. For example:
AboutPage
.
Here is a list of documentations that will help you contribute to the project:
- React - Library for building user interfaces
- Next.js - Framework for routing and server-side rendering
- Next-intl - Internationalization library
- nuqs - Easy to use query params
- Plate - Tool for rich text editing
- Tanstack Query - TRPC wraps Tanstack Query which is how we fetch data from the backend
- Tanstack Table - For dynamic tables with filtering, sorting, pagination etc
- Tanstack Form - When we need to handle form validation
- Tailwind CSS - Styling library
- Fluid for Tailwind - Fluid scale utility breakpoints
- tailwindcss-animate - Animation utility classes
- tailwind-scrollbar - Customize scrollbar with tailwind
- Class Variance Authority - Tool for creating style variants in our UI components
- shadcn/ui - Reusable UI components
- Radix UI Primitives - Primitives library that shadcn/ui is built on, great documentation if you need to access the underlying components
- Aceternity/ui - More fancy components that can be used (matches shadcn/ui)
- tsparticles - Cool particles library we can use as backgrounds
- Lucide - Icons library
- TRPC - Tool for creating API endpoints as functions
- Lucia - Authentication library
- Drizzle - ORM for interacting with the database (Postgres under the hood)
- s3-client - AWS S3 client for uploading files
- Docker - Containerization tool for the application, database and storage
- Colima - Container runtime for docker, I recommend this over Docker Desktop because of performance and license
- Docker Compose - Tool for running multi-container applications
- nginx - Reverse proxy for routing requests to the correct service
- Mozilla - Great resource for looking up documentation for web technologies
- Can I use - Check browser support for different web technologies (especially useful for CSS)
- When using custom icons that are not provided by lucide, make sure to add them as SVGs to the
components/assets/icons
folder. This improves performance since the icons are handled as vectors and not as images.
- When you want to link to a new internal page use the
<Link>
component from@/lib/navigation
instead of the normal anchortag<a>
. This will ensure that the page is loaded with the correct locale. If you want to link to external resources or other media, use the built-in<Link>
component from Next.js. Remember to addprefetch={false}
to the<Link>
component if the page is not visited often.- If you need to use both
<Link>
components from@/lib/navigation
and Next.js, make sure to import the Next.js<Link>
component asExternalLink
to avoid naming conflicts.
- If you need to use both
- Remember to surround Links with the
Button
UI component. This will provide some basic styling and accessibility features for keyboard navigation even if it is not supposed to look like a button. - For internationalization use the
useTranslations
hook fromnext-intl
. For client components you can pass the translations as props.