nextload/README.md

39 lines
2.0 KiB
Markdown
Raw Normal View History

2024-06-19 16:47:56 +00:00
## Get started with nextload
### Prerequisites:
**node**
Using a version manager for installing node is recommended, see [nvm](https://github.com/nvm-sh/nvm) or [fnm](https://github.com/Schniz/fnm)
2024-02-27 19:10:20 +00:00
2024-06-19 16:47:56 +00:00
**pnpm**
2024-06-19 19:33:32 +00:00
`corepack enable pnpm`
2024-02-27 19:10:20 +00:00
2024-06-19 16:47:56 +00:00
**docker**
2024-06-19 19:33:32 +00:00
[get docker script](https://get.docker.com/):
2024-04-10 15:17:44 +00:00
```
2024-06-19 16:47:56 +00:00
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
2024-04-10 15:17:44 +00:00
```
2024-06-19 16:47:56 +00:00
### Start developing
1. **Copy the environment variables**
2024-03-07 22:53:18 +00:00
2024-06-19 16:47:56 +00:00
`cp .env.local.example .env.example`
2024-03-07 22:53:18 +00:00
2024-06-19 16:47:56 +00:00
2. **Install dependencies**
2024-03-07 22:53:18 +00:00
2024-06-19 16:47:56 +00:00
`pnpm install`
2024-03-10 22:02:47 +00:00
2024-06-19 16:47:56 +00:00
3. **Run dev script**
2024-03-10 22:02:47 +00:00
2024-06-19 16:47:56 +00:00
`pnpm dev`
2024-03-10 22:02:47 +00:00
2024-03-05 22:16:05 +00:00
### Technical details
2024-06-19 19:33:32 +00:00
Nextload is a fork of [payload 3 demo](https://github.com/payloadcms/payload-3.0-demo)
2024-03-05 22:16:05 +00:00
**The app folder**
You'll see that Payload requires a few files to be present in your `/app` folder. There are files for the admin UI as well as files for all route handlers. We've consolidated all admin views into a single `page.tsx` and consolidated most of the REST endpoints into a single `route.ts` file for simplicity, but also for development performance. With this pattern, you only have to compile the admin UI / REST API / GraphQL API a single time - and from there, it will be lightning-fast.
2024-02-27 19:10:20 +00:00
2024-03-05 22:16:05 +00:00
**The `next.config.js` `withPayload` function**
You'll see in the Next.js config that we have a `withPayload` function installed. This function is required for Payload to operate, and it ensures compatibility with packages that Payload needs such as `drizzle-kit`, `sharp`, `pino`, and `mongodb`.
2024-03-08 00:00:06 +00:00
**Using a TypeScript alias to point to your Payload config**
2024-06-19 16:47:56 +00:00
In the `tsconfig.json` within this repo, you'll see that we have `paths` set up to point `@payload-config` to the Payload config, which is located in the root. You can put your config wherever you want. By default, the `page.tsx` files and `route.ts` files within the `/app` folder use this alias. In the future, we might make it optional to use `paths` - and by default, we might just hard-code relative path imports to the config. We would like to hear your feedback on this part. What do you prefer? Use `paths` or just use relative imports?