├── .eslintrc.json
├── app
├── favicon.ico
├── layout.tsx
├── globals.css
├── [[...page]]
│ └── page.tsx
├── data-example
│ └── page.tsx
└── section-example
│ └── page.tsx
├── next.config.js
├── postcss.config.js
├── .gitignore
├── tailwind.config.js
├── components
└── builder.tsx
├── public
├── vercel.svg
└── next.svg
├── tsconfig.json
├── package.json
└── README.md
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "next/core-web-vitals"
3 | }
4 |
--------------------------------------------------------------------------------
/app/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BuilderIO/nextjs-app-router-example/main/app/favicon.ico
--------------------------------------------------------------------------------
/next.config.js:
--------------------------------------------------------------------------------
1 | /** @type {import('next').NextConfig} */
2 | const nextConfig = {}
3 |
4 | module.exports = nextConfig
5 |
--------------------------------------------------------------------------------
/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | tailwindcss: {},
4 | autoprefixer: {},
5 | },
6 | }
7 |
--------------------------------------------------------------------------------
/app/layout.tsx:
--------------------------------------------------------------------------------
1 | import './globals.css'
2 | import { Inter } from 'next/font/google'
3 |
4 | const inter = Inter({ subsets: ['latin'] })
5 |
6 | export const metadata = {
7 | title: 'Create Next App',
8 | description: 'Generated by create next app',
9 | }
10 |
11 | export default function RootLayout({
12 | children,
13 | }: {
14 | children: React.ReactNode
15 | }) {
16 | return (
17 |
18 |
{children}
19 |
20 | )
21 | }
22 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # next.js
12 | /.next/
13 | /out/
14 |
15 | # production
16 | /build
17 |
18 | # misc
19 | .DS_Store
20 | *.pem
21 |
22 | # debug
23 | npm-debug.log*
24 | yarn-debug.log*
25 | yarn-error.log*
26 |
27 | # local env files
28 | .env*.local
29 |
30 | # vercel
31 | .vercel
32 |
33 | # typescript
34 | *.tsbuildinfo
35 | next-env.d.ts
36 |
--------------------------------------------------------------------------------
/tailwind.config.js:
--------------------------------------------------------------------------------
1 | /** @type {import('tailwindcss').Config} */
2 | module.exports = {
3 | content: [
4 | './pages/**/*.{js,ts,jsx,tsx,mdx}',
5 | './components/**/*.{js,ts,jsx,tsx,mdx}',
6 | './app/**/*.{js,ts,jsx,tsx,mdx}',
7 | ],
8 | theme: {
9 | extend: {
10 | backgroundImage: {
11 | 'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
12 | 'gradient-conic':
13 | 'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
14 | },
15 | },
16 | },
17 | plugins: [],
18 | }
19 |
--------------------------------------------------------------------------------
/components/builder.tsx:
--------------------------------------------------------------------------------
1 | "use client";
2 | import { ComponentProps } from "react";
3 | import { BuilderComponent, useIsPreviewing } from "@builder.io/react";
4 | import DefaultErrorPage from "next/error";
5 |
6 | type BuilderPageProps = ComponentProps;
7 |
8 | export function RenderBuilderContent(props: BuilderPageProps) {
9 | const isPreviewing = useIsPreviewing();
10 |
11 | if (props.content || isPreviewing) {
12 | return ;
13 | }
14 |
15 | return ;
16 | }
17 |
--------------------------------------------------------------------------------
/public/vercel.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/globals.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
4 |
5 | :root {
6 | --foreground-rgb: 0, 0, 0;
7 | --background-start-rgb: 214, 219, 220;
8 | --background-end-rgb: 255, 255, 255;
9 | }
10 |
11 | @media (prefers-color-scheme: dark) {
12 | :root {
13 | --foreground-rgb: 255, 255, 255;
14 | --background-start-rgb: 0, 0, 0;
15 | --background-end-rgb: 0, 0, 0;
16 | }
17 | }
18 |
19 | body {
20 | color: rgb(var(--foreground-rgb));
21 | background: linear-gradient(
22 | to bottom,
23 | transparent,
24 | rgb(var(--background-end-rgb))
25 | )
26 | rgb(var(--background-start-rgb));
27 | }
28 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": ["dom", "dom.iterable", "esnext"],
5 | "allowJs": true,
6 | "skipLibCheck": true,
7 | "strict": true,
8 | "forceConsistentCasingInFileNames": true,
9 | "noEmit": true,
10 | "esModuleInterop": true,
11 | "module": "esnext",
12 | "moduleResolution": "node",
13 | "resolveJsonModule": true,
14 | "isolatedModules": true,
15 | "jsx": "preserve",
16 | "incremental": true,
17 | "plugins": [
18 | {
19 | "name": "next"
20 | }
21 | ],
22 | "paths": {
23 | "@/*": ["./*"]
24 | }
25 | },
26 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
27 | "exclude": ["node_modules"]
28 | }
29 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "try-use-client",
3 | "version": "0.1.0",
4 | "private": true,
5 | "scripts": {
6 | "dev": "next dev",
7 | "build": "next build",
8 | "start": "next start",
9 | "lint": "next lint"
10 | },
11 | "dependencies": {
12 | "@builder.io/react": "^2.1.0",
13 | "@types/node": "20.1.1",
14 | "@types/react": "18.2.6",
15 | "@types/react-dom": "18.2.4",
16 | "autoprefixer": "10.4.14",
17 | "eslint": "8.40.0",
18 | "eslint-config-next": "13.4.1",
19 | "next": "13.4.1",
20 | "postcss": "8.4.23",
21 | "react": "18.2.0",
22 | "react-dom": "18.2.0",
23 | "tailwindcss": "3.3.2",
24 | "typescript": "5.0.4"
25 | },
26 | "devDependencies": {
27 | "encoding": "^0.1.13"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/[[...page]]/page.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { builder } from "@builder.io/sdk";
3 | import Head from "next/head";
4 | import { RenderBuilderContent } from "@/components/builder";
5 |
6 | // Replace with your Public API Key
7 | builder.init("YJIGb4i01jvw0SRdL5Bt");
8 |
9 | interface PageProps {
10 | params: {
11 | page: string[];
12 | };
13 | }
14 |
15 | export default async function Page(props: PageProps) {
16 | const model = "page";
17 | const content = await builder
18 | .get("page", {
19 | userAttributes: {
20 | urlPath: "/" + (props?.params?.page?.join("/") || ""),
21 | },
22 | prerender: false,
23 | })
24 | .toPromise();
25 |
26 | return (
27 | <>
28 |
29 | {content?.data.title}
30 |
31 | {/* Render the Builder page */}
32 |
33 | >
34 | );
35 | }
36 |
--------------------------------------------------------------------------------
/public/next.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/data-example/page.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { builder } from "@builder.io/sdk";
3 |
4 | // Replace with your Public API Key
5 | builder.init("YJIGb4i01jvw0SRdL5Bt");
6 |
7 | export default async function DataExample() {
8 | const menus = await builder.getAll("nav-menus", {
9 | prerender: false,
10 | });
11 |
12 | return (
13 | <>
14 |
15 |
16 | {menus.map((menu, index) => (
17 | <>
18 | {menu.data?.name}
19 | {menu.data?.submenus?.map((submenu) =>
20 | submenu.menuItems.map((menuItem, index) => (
21 |
26 | {menuItem.itemName}
27 |
28 | ))
29 | )}
30 | >
31 | ))}
32 |
33 |
34 |
44 | Your site content
45 |
46 | >
47 | );
48 | }
49 |
--------------------------------------------------------------------------------
/app/section-example/page.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { builder } from "@builder.io/sdk";
3 | import Head from "next/head";
4 | import { RenderBuilderContent } from "@/components/builder";
5 |
6 | // Replace with your Public API Key
7 | builder.init("YJIGb4i01jvw0SRdL5Bt");
8 |
9 | interface PageProps {
10 | params: {
11 | page: string[];
12 | };
13 | }
14 |
15 | export default async function SectionExample(props: PageProps) {
16 | const model = "blog-article";
17 | const content = await builder
18 | .get("blog-article", {
19 | prerender: false,
20 | })
21 | .toPromise();
22 |
23 | return (
24 | <>
25 |
26 | {content?.data.title}
27 |
28 |
37 | Non builder content
38 |
39 | {/* Render the Builder page */}
40 |
41 |
50 | Non builder content
51 |
52 | >
53 | );
54 | }
55 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
2 |
3 | ## Getting Started
4 |
5 | First, run the development server:
6 |
7 | ```bash
8 | npm run dev
9 | # or
10 | yarn dev
11 | # or
12 | pnpm dev
13 | ```
14 |
15 | Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
16 |
17 | You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
18 |
19 | This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
20 |
21 | ## Learn More
22 |
23 | To learn more about Next.js, take a look at the following resources:
24 |
25 | - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
26 | - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
27 |
28 | You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
29 |
30 | ## Deploy on Vercel
31 |
32 | The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
33 |
34 | Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
35 |
--------------------------------------------------------------------------------