Skip to content

Commit

Permalink
docs: add getting started docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aralroca committed Oct 2, 2023
1 parent 54b186c commit 0195407
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 0 deletions.
88 changes: 88 additions & 0 deletions docs/01-getting-started/01-installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
title: Installation
description: Create a new Brisa application with `create-brisa-app`.
related:
title: Next Steps
description: Learn about the files and folders in your Brisa project.
links:
- getting-started/project-structure
---

### System Requirements

- Bun [1.0.4]( https://bun.sh/) or later
- macOS, Windows (including WSL), and Linux are supported.


### Automatic Installation

We recommend starting a new Brisa app using `create-brisa-app``, which sets up everything automatically for you.

```sh
npx create-brisa-app
```

After the prompts, `create-brisa-app` will create a folder with your project name and install the required dependencies.

### Manual Installation

To manually create a new Brisa app, install the required packages:

```sh
bun install brisa@latest
```

Open your package.json file and add the following scripts:

```json
{
"scripts": {
"dev": "brisa dev",
"build": "brisa build",
"start": "brisa start"
}
}
```

These scripts refer to the different stages of developing an application:

- `dev`: runs next dev to start Brisa in development mode.
- `build`: runs next build to build the application for production usage.
- `start`: runs next start to start a Brisa production server.

You need to add the jsx-runtime of Brisa in your `tsconfig.json` file:

```json
{
"compilerOptions": {
// ...rest
"jsx": "react-jsx",
"jsxImportSource": "brisa",
}
}
```

## Creating directories

Brisa uses file-system routing (like Next.js pages) under the `src` folder. You can create a `src/pages/` directory.

Then, add an `index.tsx` file inside your `src/pages` folder. This will be your home page (`/`):

```tsx
export default function Page() {
return <h1>Hello, Brisa!</h1>
}
```

Then, add an `src/layout.tsx` file or `src/layout/index.tsx` to define the global layout. To add more layouts depending on the pages, take a look at the [layouts documentation](/docs/app/layouts.md).

### The `public` folder (optional)

Create a `public` folder to store static assets such as images, fonts, etc. Files inside public directory can then be referenced by your code starting from the base URL (`/`).

## Run the Development Server

Run npm run dev to start the development server.

- Visit http://localhost:3000 to view your application.
- Edit `src/layout/index.tsx` (or `src/pages/index.tsx`) file and save it to see the updated result in your browser.
59 changes: 59 additions & 0 deletions docs/01-getting-started/02-project-structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
title: Brisa Project Structure
nav_title: Project Structure
description: A list of folders and files conventions in a Brisa project
---

This page provides an overview of the file and folder structure of a Brisa project.

## `src`-level folders

| | |
| ------------------------------------------------------------------------ | ---------------------------------- |
| [`pages`](/docs/pages/building-your-application/routing#pages) | Pages Router |
| [`api`](/docs/pages/building-your-application/routing#api) | Api Router |
| [`public`](/docs/app/building-your-application/optimizing/static-assets) | Static assets to be served |
| [`middleware`](/docs/app/building-your-application/configuring/middleware) | Middleware |
| [`layout`](/docs/app/building-your-application/configuring/layout) | Layout / Layouts |
| [`websocket`](/docs/app/building-your-application/configuring/websocket) | Websocket |


## Top-level files

| | |
| ------------------------------------------------------------------------------------------- | --------------------------------------- |
| | |
| [`brisa.config.js`](/docs/app/api-reference/brisa-config-js) | Configuration file for Next.



### Special Files in `src/pages`

| | | |
| ----------------------------------------------------------------------------------------------------------- | ------------------- | ----------------- |
| [`_404`](/docs/pages/building-your-application/routing/custom-error#404-page) | `.js` `.jsx` `.tsx` | 404 Error Page |
| [`_500`](/docs/pages/building-your-application/routing/custom-error#500-page) | `.js` `.jsx` `.tsx` | 500 Error Page |

### Routes

| | | |
| ---------------------------------------------------------------------------------------------- | ------------------- | ----------- |
| **Folder convention** | | |
| [`index`](/docs/pages/building-your-application/routing/pages-and-layouts#index-routes) | `.js` `.jsx` `.tsx` | Home page |
| [`folder/index`](/docs/pages/building-your-application/routing/pages-and-layouts#index-routes) | `.js` `.jsx` `.tsx` | Nested page |
| **File convention** | | |
| [`index`](/docs/pages/building-your-application/routing/pages-and-layouts#index-routes) | `.js` `.jsx` `.tsx` | Home page |
| [`file`](/docs/pages/building-your-application/routing/pages-and-layouts) | `.js` `.jsx` `.tsx` | Nested page |

### Dynamic Routes

| | | |
| ----------------------------------------------------------------------------------------------------------------- | ------------------- | -------------------------------- |
| **Folder convention** | | |
| [`[folder]/index`](/docs/pages/building-your-application/routing/dynamic-routes) | `.js` `.jsx` `.tsx` | Dynamic route segment |
| [`[...folder]/index`](/docs/pages/building-your-application/routing/dynamic-routes#catch-all-segments) | `.js` `.jsx` `.tsx` | Catch-all route segment |
| [`[[...folder]]/index`](/docs/pages/building-your-application/routing/dynamic-routes#optional-catch-all-segments) | `.js` `.jsx` `.tsx` | Optional catch-all route segment |
| **File convention** | | |
| [`[file]`](/docs/pages/building-your-application/routing/dynamic-routes) | `.js` `.jsx` `.tsx` | Dynamic route segment |
| [`[...file]`](/docs/pages/building-your-application/routing/dynamic-routes#catch-all-segments) | `.js` `.jsx` `.tsx` | Catch-all route segment |
| [`[[...file]]`](/docs/pages/building-your-application/routing/dynamic-routes#optional-catch-all-segments) | `.js` `.jsx` `.tsx` | Optional catch-all route segment |
1 change: 1 addition & 0 deletions docs/02-app/02-layouts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Layouts

0 comments on commit 0195407

Please sign in to comment.