feat: whyrating - initial project from turbostarter boilerplate
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
---
|
||||
title: App configuration
|
||||
description: Learn how to setup the overall settings of your app.
|
||||
url: /docs/web/configuration/app
|
||||
---
|
||||
|
||||
# App configuration
|
||||
|
||||
The application configuration is set at `apps/web/src/config/app.ts`. This configuration stores some overall variables for your application.
|
||||
|
||||
This allows you to host multiple apps in the same monorepo, as every application defines its own configuration.
|
||||
|
||||
The recommendation is to **not update this directly** - instead, please define the environment variables and override the default behavior. The configuration is strongly typed so you can use it safely accross your codebase - it'll be validated at build time.
|
||||
|
||||
```ts title="apps/web/src/config/app.ts"
|
||||
import env from "env.config";
|
||||
|
||||
export const appConfig = {
|
||||
name: env.NEXT_PUBLIC_PRODUCT_NAME,
|
||||
url: env.NEXT_PUBLIC_URL,
|
||||
locale: env.NEXT_PUBLIC_DEFAULT_LOCALE,
|
||||
theme: {
|
||||
mode: env.NEXT_PUBLIC_THEME_MODE,
|
||||
color: env.NEXT_PUBLIC_THEME_COLOR,
|
||||
},
|
||||
} as const;
|
||||
```
|
||||
|
||||
For example, to set the product name and default locale, you'd update the following variables:
|
||||
|
||||
```dotenv title=".env.local"
|
||||
NEXT_PUBLIC_PRODUCT_NAME="TurboStarter"
|
||||
NEXT_PUBLIC_DEFAULT_LOCALE="en"
|
||||
```
|
||||
|
||||
<Callout type="warn" title="Do NOT use process.env!">
|
||||
Do NOT use `process.env` to get the values of the variables. Variables
|
||||
accessed this way are not validated at build time, and thus the wrong variable
|
||||
can be used in production.
|
||||
</Callout>
|
||||
@@ -0,0 +1,104 @@
|
||||
---
|
||||
title: Environment variables
|
||||
description: Learn how to configure environment variables.
|
||||
url: /docs/web/configuration/environment-variables
|
||||
---
|
||||
|
||||
# Environment variables
|
||||
|
||||
Environment variables are defined in the `.env` file in the root of the repository and in the root of the `apps/web` package.
|
||||
|
||||
* **Shared environment variables**: Defined in the **root** `.env` file. These are shared between environments (e.g., development, staging, production) and apps (e.g., web, mobile).
|
||||
* **Environment-specific variables**: Defined in `.env.development` and `.env.production` files. These are specific to the development and production environments.
|
||||
* **App-specific variables**: Defined in the app-specific directory (e.g., `apps/web`). These are specific to the app and are not shared between apps.
|
||||
* **Secret keys**: Not stored in the `.env` file. Instead, they are stored in the environment variables of the CI/CD system.
|
||||
* **Local secret keys**: If you need to use secret keys locally, you can store them in the `.env.local` file. This file is not committed to Git, making it safe for sensitive information.
|
||||
|
||||
## Shared variables
|
||||
|
||||
Here you can add all the environment variables that are shared across all the apps. This file should be located in the **root** of the project.
|
||||
|
||||
To override these variables in a specific environment, please add them to the specific environment file (e.g. `.env.development`, `.env.production`).
|
||||
|
||||
```dotenv title=".env.local"
|
||||
# Shared environment variables
|
||||
|
||||
# The database URL is used to connect to your database.
|
||||
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres"
|
||||
|
||||
# The name of the product. This is used in various places across the apps.
|
||||
PRODUCT_NAME="TurboStarter"
|
||||
|
||||
# The url of the web app. Used mostly to link between apps.
|
||||
URL="http://localhost:3000"
|
||||
|
||||
...
|
||||
```
|
||||
|
||||
If you're using Supabase for your database, the [Supabase recipe](/docs/web/recipes/supabase#configure-environment-variables) shows the exact `DATABASE_URL` format and how to set it in your `.env.local`.
|
||||
|
||||
## App-specific variables
|
||||
|
||||
Here you can add all the environment variables that are specific to the app (e.g. `apps/web`).
|
||||
|
||||
You can also override the shared variables defined in the root `.env` file.
|
||||
|
||||
```dotenv title="apps/web/.env.local"
|
||||
# App-specific environment variables
|
||||
|
||||
# Env variables extracted from shared to be exposed to the client in Next.js app
|
||||
NEXT_PUBLIC_PRODUCT_NAME="${PRODUCT_NAME}"
|
||||
NEXT_PUBLIC_URL="${URL}"
|
||||
NEXT_PUBLIC_DEFAULT_LOCALE="${DEFAULT_LOCALE}"
|
||||
|
||||
# Theme mode and color
|
||||
NEXT_PUBLIC_THEME_MODE="system"
|
||||
NEXT_PUBLIC_THEME_COLOR="orange"
|
||||
|
||||
...
|
||||
```
|
||||
|
||||
<Callout title="NEXT_PUBLIC_ prefix">
|
||||
To make environment variables available in the Next.js **client-side** app code, you need to prefix them with `NEXT_PUBLIC_`. They will be injected to the code during the build process.
|
||||
|
||||
Only environment variables prefixed with `NEXT_PUBLIC_` will be injected, so don't use this prefix for environment variables that should be used only in the server-side code.
|
||||
|
||||
[Read more about Next.js environment variables.](https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables)
|
||||
</Callout>
|
||||
|
||||
## Secret keys
|
||||
|
||||
Secret keys and sensitive information are to be never stored in the `.env` file. Instead, **they are stored in the environment variables of the CI/CD system.**
|
||||
|
||||
<Callout title="What does this mean?">
|
||||
It means that you will need to add the secret keys to the environment
|
||||
variables of your CI/CD system (e.g., GitHub Actions, Vercel, Cloudflare, your
|
||||
VPS, Netlify, etc.). This is not a TurboStarter-specific requirement, but a
|
||||
best practice for security for any application. Ultimately, it's your choice.
|
||||
</Callout>
|
||||
|
||||
Below is some examples of "what is a secret key?" in practice.
|
||||
|
||||
```dotenv title=".env.local"
|
||||
# Secret keys
|
||||
|
||||
# The database URL is used to connect to your database.
|
||||
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres"
|
||||
|
||||
# Stripe server config - required only if you use Stripe as a billing provider
|
||||
STRIPE_WEBHOOK_SECRET=""
|
||||
STRIPE_SECRET_KEY=""
|
||||
|
||||
# Lemon Squeezy server config - required only if you use Lemon Squeezy as a billing provider
|
||||
LEMON_SQUEEZY_API_KEY=""
|
||||
LEMON_SQUEEZY_SIGNING_SECRET=""
|
||||
LEMON_SQUEEZY_STORE_ID=""
|
||||
|
||||
...
|
||||
```
|
||||
|
||||
<Callout title="Secrets used locally">
|
||||
If you need to use secret keys locally, you can store them in the `.env.local`
|
||||
file. This file is not committed to Git, therefore it is safe to store
|
||||
sensitive information in it.
|
||||
</Callout>
|
||||
@@ -0,0 +1,52 @@
|
||||
---
|
||||
title: Paths configuration
|
||||
description: Learn how to configure the paths of your app.
|
||||
url: /docs/web/configuration/paths
|
||||
---
|
||||
|
||||
# Paths configuration
|
||||
|
||||
The paths configuration is set at `apps/web/config/paths.ts`. This configuration stores all the paths that you'll be using in your application. It is a convenient way to store them in a central place rather than scatter them in the codebase using magic strings.
|
||||
|
||||
It is **unlikely you'll need to change** this unless you're heavily editing the codebase.
|
||||
|
||||
```ts title="apps/web/config/paths.ts"
|
||||
const pathsConfig = {
|
||||
index: "/",
|
||||
marketing: {
|
||||
pricing: "/pricing",
|
||||
contact: "/contact",
|
||||
blog: {
|
||||
index: BLOG_PREFIX,
|
||||
post: (slug: string) => `${BLOG_PREFIX}/${slug}`,
|
||||
},
|
||||
legal: (slug: string) => `${LEGAL_PREFIX}/${slug}`,
|
||||
},
|
||||
auth: {
|
||||
login: `${AUTH_PREFIX}/login`,
|
||||
register: `${AUTH_PREFIX}/register`,
|
||||
join: `${AUTH_PREFIX}/join`,
|
||||
forgotPassword: `${AUTH_PREFIX}/password/forgot`,
|
||||
updatePassword: `${AUTH_PREFIX}/password/update`,
|
||||
error: `${AUTH_PREFIX}/error`,
|
||||
},
|
||||
dashboard: {
|
||||
user: {
|
||||
index: DASHBOARD_PREFIX,
|
||||
ai: `${DASHBOARD_PREFIX}/ai`,
|
||||
settings: {
|
||||
index: `${DASHBOARD_PREFIX}/settings`,
|
||||
security: `${DASHBOARD_PREFIX}/settings/security`,
|
||||
billing: `${DASHBOARD_PREFIX}/settings/billing`,
|
||||
},
|
||||
},
|
||||
...
|
||||
},
|
||||
...,
|
||||
} as const;
|
||||
```
|
||||
|
||||
<Callout title="Fully type-safe">
|
||||
By declaring the paths as constants, we can use them safely throughout the
|
||||
codebase. There is no risk of misspelling or using magic strings.
|
||||
</Callout>
|
||||
Reference in New Issue
Block a user