Gel on Next.js

R
Renaudil y a 2 jours
0

Description

Starter template for Gel and Next.js. It includes a basic Gel schema and a UI to get you started.

npx boilerapp gel

文档

🎉 Gel + Next.js template

This starter is designed to help you get up and running with Gel and Next.js quickly. It includes a basic Gel schema and a UI to get you started. Below you can find the steps to set up the project and start building your app as well as some ideas for extending it further.

Deploy with Vercel

This template includes:

🧐 What's inside?

.
├── README.md
├── app
│   ├── favicon.ico
│   ├── globals.css
│   ├── layout.tsx
│   └── page.tsx
├── components/
├── src/
├── public/
├── dbschema
│   ├── default.esdl
├── gel.toml
├── eslint.config.js
├── next-env.d.ts
├── next.config.js
├── package.json
├── pnpm-lock.yaml
├── postcss.config.js
├── tailwind.config.ts
└── tsconfig.json

Directory structure:

  • app/ - Next.js pages and components
  • public/ - static assets
  • components/ - React components
  • src/ - utility functions
  • dbschema/ - Gel schema and migrations
  • gel.toml - Gel configuration
  • gel.ts - Gel client
  • eslint.config.js - ESLint configuration
  • next-env.d.ts - Next.js types
  • next.config.js - Next.js configuration
  • package.json - npm dependencies
  • pnpm-lock.yaml - pnpm lockfile
  • postcss.config.js - PostCSS configuration
  • tailwind.config.ts - Tailwind CSS configuration
  • tsconfig.json - TypeScript configuration

🚀 Quick start

To get started with this template, you need to:

1. Clone the repository & install dependencies

git clone https://github.com/geldata/nextjs-gel-basic-template.git
cd nextjs-gel-basic-template

pnpm i

You can also click the "Use this template" button to create a new repository based on this template.

2. Install Gel CLI (optional)

You can just use npx gel, it would do the right thing to automatically install and run Gel CLI for you.

This README will use npx gel <command> style, but if you have the CLI installed you can use it directly, like this: gel <command>.

<details><summary>However, you can install the CLI manually</summary>
curl --proto '=https' --tlsv1.2 -sSf https://sh.geldata.com | sh

For more installation options, see the Gel installation guide.

</details>

3. Initialize Gel project

To run this project, you need to initialize a new Gel project. Run the following command:

npx gel project init

4. Generate types

This template includes a script to generate TypeScript types from the Gel schema. Run the following command:

pnpm generate:all

5. Start the development server

pnpm dev

Follow the instructions in the terminal to open the app in your browser.

6. Open the Gel UI

To view the database in the Gel UI run:

npx gel ui

✨ Next steps

Extend the Gel schema

Open the dbschema/default.gel file and add your own types and fields. You can start by adding a Post type with a title and content field. For example:

type Post {
  # Add your new fields here:
  required title: str;
  required content: str;
}

Edit the Gel query

Open the app/page.tsx file and update the query to include your new type.

const postsQuery = e.select(e.Post, (_post) => ({
  id: true,
  title: true,
  content: true,
  // Add your other fields here
}))

👩‍🏫 Learn More

Explore a list of resources to help you get started with Gel and Next.js:

To learn more about Next.js, take a look at the following resources:

You can also check out the Gel documentation to learn more about Gel and Gel Auth.

☁️ Deployment

Follow the deployment instructions in the Gel documentation to deploy your Next.js app to Gel Cloud and Vercel.

Or

Deploy with Vercel

Prix

Gratuit

FREE

评论 (0)

常见问题

常见问题解答 (FAQ)

有问题?我们有答案。如果您找不到想要的答案,请随时联络我们。

Boilerapp 是一个专门用于分享 Boilerplates、入门套件(Starter Kits)和项目模版的开发者社区平台。我们的目标很简单:为您节省初始配置(Setup)的时间,让您可以专注于真正重要的代码。无论您是在寻找简单的代码库还是完整的 SaaS 项目,都能在这里找到。

还有其他问题?

我们的团队随时为您提供帮助。联络我们,我们将尽快回复。