create-plasmic-app 0.0.133 → 0.0.135

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/cpa-out/nextjs-app-codegen-js/app/dynamic/[slug]/page-client.jsx +7 -0
  2. package/cpa-out/nextjs-app-codegen-js/app/dynamic/[slug]/page.jsx +45 -0
  3. package/cpa-out/nextjs-app-codegen-js/app/layout.js +28 -0
  4. package/cpa-out/nextjs-app-codegen-js/app/layout.jsx +17 -0
  5. package/cpa-out/nextjs-app-codegen-js/app/page-client.jsx +7 -0
  6. package/cpa-out/nextjs-app-codegen-js/app/page.jsx +45 -0
  7. package/cpa-out/nextjs-app-codegen-js/app/plasmic-host/page.jsx +15 -0
  8. package/cpa-out/nextjs-app-codegen-js/components/Button.jsx +11 -0
  9. package/cpa-out/nextjs-app-codegen-js/components/RandomDynamicPageButton.jsx +24 -0
  10. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicButton.jsx +595 -0
  11. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicDynamicPage.jsx +216 -0
  12. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicDynamicPageServer.jsx +56 -0
  13. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.jsx +26 -0
  14. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicHomepage.jsx +251 -0
  15. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicHomepageServer.jsx +56 -0
  16. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.jsx +159 -0
  17. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicStyleTokensProvider.jsx +15 -0
  18. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/icons/PlasmicIcon__CheckSvg.jsx +39 -0
  19. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Icon.jsx +37 -0
  20. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/plasmic.jsx +11 -0
  21. package/cpa-out/nextjs-app-codegen-js/package.json +22 -0
  22. package/cpa-out/nextjs-app-codegen-js/plasmic.json +148 -0
  23. package/cpa-out/nextjs-app-codegen-ts/app/dynamic/[slug]/page-client.tsx +11 -0
  24. package/cpa-out/nextjs-app-codegen-ts/app/dynamic/[slug]/page.tsx +57 -0
  25. package/cpa-out/nextjs-app-codegen-ts/app/layout.tsx +19 -0
  26. package/cpa-out/nextjs-app-codegen-ts/app/page-client.tsx +11 -0
  27. package/cpa-out/nextjs-app-codegen-ts/app/page.tsx +54 -0
  28. package/cpa-out/nextjs-app-codegen-ts/app/plasmic-host/page.tsx +15 -0
  29. package/cpa-out/nextjs-app-codegen-ts/components/Button.tsx +35 -0
  30. package/cpa-out/nextjs-app-codegen-ts/components/RandomDynamicPageButton.tsx +44 -0
  31. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicButton.tsx +776 -0
  32. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicDynamicPage.tsx +329 -0
  33. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicDynamicPageServer.tsx +77 -0
  34. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.tsx +30 -0
  35. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicHomepage.tsx +366 -0
  36. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicHomepageServer.tsx +75 -0
  37. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.tsx +274 -0
  38. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicStyleTokensProvider.tsx +19 -0
  39. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/icons/PlasmicIcon__CheckSvg.tsx +44 -0
  40. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Icon.tsx +41 -0
  41. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/plasmic.tsx +14 -0
  42. package/cpa-out/nextjs-app-codegen-ts/package.json +26 -0
  43. package/cpa-out/nextjs-app-codegen-ts/plasmic.json +148 -0
  44. package/cpa-out/nextjs-app-codegen-ts/tsconfig.json +26 -0
  45. package/cpa-out/nextjs-app-loader-js/app/[[...catchall]]/page.jsx +80 -0
  46. package/cpa-out/nextjs-app-loader-js/app/layout.js +28 -0
  47. package/cpa-out/nextjs-app-loader-js/app/plasmic-host/page.jsx +6 -0
  48. package/cpa-out/nextjs-app-loader-js/plasmic-init-client.jsx +65 -0
  49. package/cpa-out/nextjs-app-loader-js/plasmic-init.js +5 -10
  50. package/cpa-out/nextjs-app-loader-ts/app/[[...catchall]]/page.tsx +85 -0
  51. package/cpa-out/nextjs-app-loader-ts/app/layout.tsx +33 -0
  52. package/cpa-out/nextjs-app-loader-ts/app/plasmic-host/page.tsx +6 -0
  53. package/cpa-out/nextjs-app-loader-ts/plasmic-init-client.tsx +65 -0
  54. package/cpa-out/nextjs-app-loader-ts/plasmic-init.ts +5 -10
  55. package/cpa-out/nextjs-app-loader-ts/tsconfig.json +6 -1
  56. package/dist/index.js +31 -30
  57. package/dist/nextjs/nextjs.js +37 -11
  58. package/dist/nextjs/templates/app-codegen/layout.d.ts +2 -0
  59. package/dist/nextjs/templates/app-codegen/layout.js +27 -0
  60. package/dist/nextjs/templates/app-loader/catchall-page.js +63 -38
  61. package/dist/nextjs/templates/app-loader/plasmic-init-client.js +1 -1
  62. package/dist/nextjs/templates/app-loader/plasmic-init.js +4 -0
  63. package/package.json +2 -2
  64. package/run-cpa.ts +8 -9
  65. package/src/index.ts +31 -36
  66. package/src/nextjs/nextjs.ts +67 -28
  67. package/src/nextjs/templates/app-codegen/layout.ts +28 -0
  68. package/src/nextjs/templates/app-loader/catchall-page.ts +80 -43
  69. package/src/nextjs/templates/app-loader/plasmic-init-client.ts +1 -1
  70. package/src/nextjs/templates/app-loader/plasmic-init.ts +4 -0
  71. package/cpa-out/nextjs-app-loader-js/pages/[[...catchall]].jsx +0 -68
  72. package/cpa-out/nextjs-app-loader-js/pages/api/hello.js +0 -5
  73. package/cpa-out/nextjs-app-loader-js/pages/plasmic-host.jsx +0 -7
  74. package/cpa-out/nextjs-app-loader-ts/pages/[[...catchall]].tsx +0 -72
  75. package/cpa-out/nextjs-app-loader-ts/pages/api/hello.ts +0 -13
  76. package/cpa-out/nextjs-app-loader-ts/pages/plasmic-host.tsx +0 -7
@@ -0,0 +1,19 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+ // @ts-nocheck
4
+
5
+ // This code is auto-generated by Plasmic; please do not edit!
6
+ // Plasmic Project: 47tFXWjN2C4NyHFGGpaYQ3
7
+
8
+ import { createUseStyleTokens } from "@plasmicapp/react-web";
9
+
10
+ import { _useGlobalVariants } from "./plasmic"; // plasmic-import: 47tFXWjN2C4NyHFGGpaYQ3/projectModule
11
+
12
+ import projectcss from "./plasmic.module.css"; // plasmic-import: 47tFXWjN2C4NyHFGGpaYQ3/projectcss
13
+
14
+ const data = {
15
+ base: `${projectcss.plasmic_tokens}`,
16
+ varianted: []
17
+ };
18
+
19
+ export const _useStyleTokens = createUseStyleTokens(data, _useGlobalVariants);
@@ -0,0 +1,44 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+ // @ts-nocheck
4
+ /* prettier-ignore-start */
5
+ import React from "react";
6
+ import { classNames } from "@plasmicapp/react-web";
7
+
8
+ export type CheckSvgIconProps = React.ComponentProps<"svg"> & {
9
+ title?: string;
10
+ };
11
+
12
+ export function CheckSvgIcon(props: CheckSvgIconProps) {
13
+ const { className, style, title, ...restProps } = props;
14
+ return (
15
+ <svg
16
+ xmlns={"http://www.w3.org/2000/svg"}
17
+ fill={"none"}
18
+ viewBox={"0 0 24 24"}
19
+ height={"1em"}
20
+ width={"1em"}
21
+ style={{
22
+ fill: "currentcolor",
23
+
24
+ ...(style || {})
25
+ }}
26
+ className={classNames("plasmic-default__svg", className)}
27
+ {...restProps}
28
+ >
29
+ {title && <title>{title}</title>}
30
+
31
+ <path
32
+ fillRule={"evenodd"}
33
+ clipRule={"evenodd"}
34
+ d={
35
+ "M18.416 5.876a.75.75 0 01.208 1.04L11.42 17.721a1.75 1.75 0 01-2.871.06l-3.156-4.34a.75.75 0 111.214-.882l3.155 4.339a.25.25 0 00.41-.009l7.204-10.805a.75.75 0 011.04-.208z"
36
+ }
37
+ fill={"currentColor"}
38
+ ></path>
39
+ </svg>
40
+ );
41
+ }
42
+
43
+ export default CheckSvgIcon;
44
+ /* prettier-ignore-end */
@@ -0,0 +1,41 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+ // @ts-nocheck
4
+ /* prettier-ignore-start */
5
+ import React from "react";
6
+ import { classNames } from "@plasmicapp/react-web";
7
+
8
+ export type IconIconProps = React.ComponentProps<"svg"> & {
9
+ title?: string;
10
+ };
11
+
12
+ export function IconIcon(props: IconIconProps) {
13
+ const { className, style, title, ...restProps } = props;
14
+ return (
15
+ <svg
16
+ xmlns={"http://www.w3.org/2000/svg"}
17
+ stroke={"currentColor"}
18
+ fill={"currentColor"}
19
+ strokeWidth={"0"}
20
+ viewBox={"0 0 16 16"}
21
+ height={"1em"}
22
+ width={"1em"}
23
+ className={classNames("plasmic-default__svg", className)}
24
+ style={style}
25
+ {...restProps}
26
+ >
27
+ {title && <title>{title}</title>}
28
+
29
+ <path
30
+ fillRule={"evenodd"}
31
+ d={
32
+ "M1 8a.5.5 0 01.5-.5h11.793l-3.147-3.146a.5.5 0 01.708-.708l4 4a.5.5 0 010 .708l-4 4a.5.5 0 01-.708-.708L13.293 8.5H1.5A.5.5 0 011 8z"
33
+ }
34
+ stroke={"none"}
35
+ ></path>
36
+ </svg>
37
+ );
38
+ }
39
+
40
+ export default IconIcon;
41
+ /* prettier-ignore-end */
@@ -0,0 +1,14 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+ // @ts-nocheck
4
+
5
+ // This code is auto-generated by Plasmic; please do not edit!
6
+ // Plasmic Project: 47tFXWjN2C4NyHFGGpaYQ3
7
+
8
+ import { createUseGlobalVariants } from "@plasmicapp/react-web";
9
+
10
+ import { useScreenVariants as useScreenVariantsscBjPxgdxdzbv } from "./PlasmicGlobalVariant__Screen"; // plasmic-import: SCBjPXGDXDZBV/globalVariant
11
+
12
+ export const _useGlobalVariants = createUseGlobalVariants({
13
+ screen: useScreenVariantsscBjPxgdxdzbv
14
+ });
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "nextjs-app-codegen-ts",
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
+ "@plasmicapp/cli": "^0.1.359",
13
+ "@plasmicapp/react-web": "^0.2.422",
14
+ "next": "14.2.35",
15
+ "react": "^18",
16
+ "react-dom": "^18"
17
+ },
18
+ "devDependencies": {
19
+ "@types/node": "^20",
20
+ "@types/react": "^18",
21
+ "@types/react-dom": "^18",
22
+ "eslint": "^8",
23
+ "eslint-config-next": "14.2.35",
24
+ "typescript": "^5"
25
+ }
26
+ }
@@ -0,0 +1,148 @@
1
+ {
2
+ "platform": "nextjs",
3
+ "code": {
4
+ "lang": "ts",
5
+ "scheme": "blackbox",
6
+ "reactRuntime": "classic"
7
+ },
8
+ "style": {
9
+ "scheme": "css-modules",
10
+ "defaultStyleCssFilePath": "plasmic/plasmic__default_style.module.css"
11
+ },
12
+ "images": {
13
+ "scheme": "public-files",
14
+ "publicDir": "../public",
15
+ "publicUrlPrefix": "/"
16
+ },
17
+ "tokens": {
18
+ "scheme": "theo",
19
+ "tokensFilePath": "plasmic-tokens.theo.json"
20
+ },
21
+ "srcDir": "components",
22
+ "defaultPlasmicDir": "./plasmic",
23
+ "projects": [
24
+ {
25
+ "projectId": "47tFXWjN2C4NyHFGGpaYQ3",
26
+ "projectApiToken": "7BRFratDxPLMGZHnd2grV5QP6mlHcZ1AK3BJSIeh7xzUlHgWh25XpgXvUaKAqHXFMXQQuzpADqboibF6nqNWQ",
27
+ "projectName": "create-plasmic-app",
28
+ "version": "latest",
29
+ "cssFilePath": "plasmic/create_plasmic_app/plasmic.module.css",
30
+ "components": [
31
+ {
32
+ "id": "6uuAAE1jiCew",
33
+ "name": "Homepage",
34
+ "type": "managed",
35
+ "projectId": "47tFXWjN2C4NyHFGGpaYQ3",
36
+ "renderModuleFilePath": "plasmic/create_plasmic_app/PlasmicHomepage.tsx",
37
+ "importSpec": {
38
+ "modulePath": "../app/page.tsx"
39
+ },
40
+ "cssFilePath": "plasmic/create_plasmic_app/PlasmicHomepage.module.css",
41
+ "scheme": "blackbox",
42
+ "componentType": "page",
43
+ "path": "/",
44
+ "rsc": {
45
+ "serverModulePath": "plasmic/create_plasmic_app/PlasmicHomepageServer.tsx",
46
+ "clientModulePath": "../app/page-client.tsx"
47
+ }
48
+ },
49
+ {
50
+ "id": "AO44A-w7hh",
51
+ "name": "DynamicPage",
52
+ "type": "managed",
53
+ "projectId": "47tFXWjN2C4NyHFGGpaYQ3",
54
+ "renderModuleFilePath": "plasmic/create_plasmic_app/PlasmicDynamicPage.tsx",
55
+ "importSpec": {
56
+ "modulePath": "../app/dynamic/[slug]/page.tsx"
57
+ },
58
+ "cssFilePath": "plasmic/create_plasmic_app/PlasmicDynamicPage.module.css",
59
+ "scheme": "blackbox",
60
+ "componentType": "page",
61
+ "path": "/dynamic/[slug]",
62
+ "rsc": {
63
+ "serverModulePath": "plasmic/create_plasmic_app/PlasmicDynamicPageServer.tsx",
64
+ "clientModulePath": "../app/dynamic/[slug]/page-client.tsx"
65
+ }
66
+ },
67
+ {
68
+ "id": "TQcvW_pSKi3",
69
+ "name": "Button",
70
+ "type": "managed",
71
+ "projectId": "47tFXWjN2C4NyHFGGpaYQ3",
72
+ "renderModuleFilePath": "plasmic/create_plasmic_app/PlasmicButton.tsx",
73
+ "importSpec": {
74
+ "modulePath": "Button.tsx"
75
+ },
76
+ "cssFilePath": "plasmic/create_plasmic_app/PlasmicButton.module.css",
77
+ "scheme": "blackbox",
78
+ "componentType": "component",
79
+ "plumeType": "button"
80
+ },
81
+ {
82
+ "id": "Q23H1_1M_P",
83
+ "name": "RandomDynamicPageButton",
84
+ "type": "managed",
85
+ "projectId": "47tFXWjN2C4NyHFGGpaYQ3",
86
+ "renderModuleFilePath": "plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.tsx",
87
+ "importSpec": {
88
+ "modulePath": "RandomDynamicPageButton.tsx"
89
+ },
90
+ "cssFilePath": "plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.module.css",
91
+ "scheme": "blackbox",
92
+ "componentType": "component"
93
+ }
94
+ ],
95
+ "icons": [
96
+ {
97
+ "id": "gj-_D7n31Ho",
98
+ "name": "CheckSvgIcon",
99
+ "moduleFilePath": "plasmic/create_plasmic_app/icons/PlasmicIcon__CheckSvg.tsx"
100
+ },
101
+ {
102
+ "id": "6PNxx3YMyDQ",
103
+ "name": "IconIcon",
104
+ "moduleFilePath": "plasmic/create_plasmic_app/icons/PlasmicIcon__Icon.tsx"
105
+ }
106
+ ],
107
+ "images": [],
108
+ "indirect": false,
109
+ "globalContextsFilePath": "",
110
+ "splitsProviderFilePath": "",
111
+ "styleTokensProviderFilePath": "plasmic/create_plasmic_app/PlasmicStyleTokensProvider.tsx",
112
+ "dataTokensFilePath": "",
113
+ "projectModuleFilePath": "plasmic/create_plasmic_app/plasmic.tsx",
114
+ "codeComponents": [
115
+ {
116
+ "id": "P6aGdYWZ2R",
117
+ "name": "PlasmicHead",
118
+ "displayName": "hostless-plasmic-head",
119
+ "componentImportPath": "@plasmicapp/react-web"
120
+ },
121
+ {
122
+ "id": "8G2A-uTjGa",
123
+ "name": "Fetcher",
124
+ "displayName": "plasmic-data-source-fetcher",
125
+ "componentImportPath": "@plasmicapp/react-web/lib/data-sources"
126
+ }
127
+ ],
128
+ "customFunctions": []
129
+ }
130
+ ],
131
+ "globalVariants": {
132
+ "variantGroups": [
133
+ {
134
+ "id": "SCBjPXGDXDZBV",
135
+ "name": "Screen",
136
+ "projectId": "47tFXWjN2C4NyHFGGpaYQ3",
137
+ "contextFilePath": "plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.tsx"
138
+ }
139
+ ]
140
+ },
141
+ "wrapPagesWithGlobalContexts": true,
142
+ "preserveJsImportExtensions": false,
143
+ "nextjsConfig": {
144
+ "pagesDir": "../app"
145
+ },
146
+ "cliVersion": "0.1.359",
147
+ "$schema": "https://unpkg.com/@plasmicapp/cli@0.1.359/dist/plasmic.schema.json"
148
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["dom", "dom.iterable", "esnext"],
4
+ "allowJs": true,
5
+ "skipLibCheck": true,
6
+ "strict": true,
7
+ "noEmit": true,
8
+ "esModuleInterop": true,
9
+ "module": "esnext",
10
+ "moduleResolution": "bundler",
11
+ "resolveJsonModule": true,
12
+ "isolatedModules": true,
13
+ "jsx": "preserve",
14
+ "incremental": true,
15
+ "plugins": [
16
+ {
17
+ "name": "next"
18
+ }
19
+ ],
20
+ "paths": {
21
+ "@/*": ["./*"]
22
+ }
23
+ },
24
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
25
+ "exclude": ["node_modules"]
26
+ }
@@ -0,0 +1,80 @@
1
+ import { PLASMIC } from "@/plasmic-init";
2
+ import { ClientPlasmicRootProvider } from "@/plasmic-init-client";
3
+ import { PlasmicComponent } from "@plasmicapp/loader-nextjs";
4
+ import { notFound } from "next/navigation";
5
+
6
+ // Use revalidate if you want incremental static regeneration
7
+ export const revalidate = 60;
8
+
9
+ export async function generateStaticParams() {
10
+ const pageModules = await PLASMIC.fetchPages();
11
+ return pageModules.map((mod) => {
12
+ const catchall =
13
+ mod.path === "/" ? undefined : mod.path.substring(1).split("/");
14
+ return {
15
+ catchall,
16
+ };
17
+ });
18
+ }
19
+
20
+ export async function generateMetadata(
21
+ { params },
22
+ parent
23
+ ) {
24
+ const { componentData } = await getPlasmicData(params);
25
+
26
+ if (!componentData) {
27
+ return parent;
28
+ }
29
+ const pageMeta = componentData.entryCompMetas[0];
30
+ const metadata = await PLASMIC.unstable__generateMetadata(componentData, {
31
+ params: pageMeta.params ?? {},
32
+ query: {},
33
+ });
34
+
35
+ return { ...(await parent), ...metadata };
36
+ }
37
+
38
+ export default async function PlasmicLoaderPage({
39
+ params,
40
+ }) {
41
+ const { pagePath, componentData } = await getPlasmicData(params);
42
+
43
+ if (!componentData) {
44
+ notFound();
45
+ }
46
+ const pageMeta = componentData.entryCompMetas[0];
47
+ const prefetchedQueryData = await PLASMIC.unstable__getServerQueriesData(
48
+ componentData,
49
+ {
50
+ pagePath,
51
+ params: pageMeta.params,
52
+ query: {},
53
+ }
54
+ );
55
+
56
+ return (
57
+ <ClientPlasmicRootProvider
58
+ prefetchedData={componentData}
59
+ prefetchedQueryData={prefetchedQueryData}
60
+ pageParams={pageMeta.params}
61
+ pageRoute={pageMeta.path}
62
+ >
63
+ <PlasmicComponent component={pageMeta.displayName} />
64
+ </ClientPlasmicRootProvider>
65
+ );
66
+ }
67
+
68
+ async function getPlasmicData(
69
+ params
70
+ ) {
71
+ const catchall = (await params).catchall;
72
+ const pagePath = catchall ? `/${catchall.join("/")}` : "/";
73
+
74
+ const componentData = await PLASMIC.maybeFetchComponentData(pagePath);
75
+
76
+ if (!componentData || componentData.entryCompMetas.length === 0) {
77
+ return { pagePath };
78
+ }
79
+ return { pagePath, componentData };
80
+ }
@@ -0,0 +1,28 @@
1
+ import localFont from "next/font/local";
2
+ import "./globals.css";
3
+
4
+ const geistSans = localFont({
5
+ src: "./fonts/GeistVF.woff",
6
+ variable: "--font-geist-sans",
7
+ weight: "100 900",
8
+ });
9
+ const geistMono = localFont({
10
+ src: "./fonts/GeistMonoVF.woff",
11
+ variable: "--font-geist-mono",
12
+ weight: "100 900",
13
+ });
14
+
15
+ export const metadata = {
16
+ title: "Create Next App",
17
+ description: "Generated by create next app",
18
+ };
19
+
20
+ export default function RootLayout({ children }) {
21
+ return (
22
+ <html lang="en">
23
+ <body className={`${geistSans.variable} ${geistMono.variable}`}>
24
+ {children}
25
+ </body>
26
+ </html>
27
+ );
28
+ }
@@ -0,0 +1,6 @@
1
+ import { PlasmicCanvasHost } from "@plasmicapp/loader-nextjs";
2
+ import "@/plasmic-init-client";
3
+
4
+ export default function PlasmicHost() {
5
+ return <PlasmicCanvasHost />;
6
+ }
@@ -0,0 +1,65 @@
1
+ "use client";
2
+
3
+ import { PlasmicRootProvider } from "@plasmicapp/loader-nextjs";
4
+ import { PLASMIC } from "@/plasmic-init";
5
+
6
+ // You can register any code components that you want to use here; see
7
+ // https://docs.plasmic.app/learn/code-components-ref/
8
+ // And configure your Plasmic project to use the host url pointing at
9
+ // the /plasmic-host page of your nextjs app (for example,
10
+ // http://localhost:3000/plasmic-host). See
11
+ // https://docs.plasmic.app/learn/app-hosting/#set-a-plasmic-project-to-use-your-app-host
12
+
13
+ // PLASMIC.registerComponent(...);
14
+
15
+ /**
16
+ * ClientPlasmicRootProvider is a Client Component that passes in the loader for you.
17
+ *
18
+ * Why? Props passed from Server to Client Components must be serializable.
19
+ * https://nextjs.org/docs/app/getting-started/server-and-client-components#passing-data-from-server-to-client-components
20
+ * However, PlasmicRootProvider requires a loader, but the loader is NOT serializable.
21
+ *
22
+ * In a Server Component like app/<your-path>/path.tsx, rendering the following would not work:
23
+ *
24
+ * ```tsx
25
+ * import { PLASMIC } from "@/plasmic-init";
26
+ * import { PlasmicRootProvider } from "plasmicapp/loader-nextjs";
27
+ * export default function MyPage() {
28
+ * const prefetchedData = await PLASMIC.fetchComponentData("YourPage");
29
+ * return (
30
+ * <PlasmicRootProvider
31
+ * loader={PLASMIC} // ERROR: loader is not serializable
32
+ * prefetchedData={prefetchedData}
33
+ * >
34
+ * {yourContent()}
35
+ * </PlasmicRootProvider>;
36
+ * );
37
+ * }
38
+ * ```
39
+ *
40
+ * Therefore, we define ClientPlasmicRootProvider as a Client Component (this file is marked "use client").
41
+ * ClientPlasmicRootProvider wraps the PlasmicRootProvider and passes in the loader for you,
42
+ * while allowing your Server Component to pass in prefetched data and other serializable props:
43
+ *
44
+ * ```tsx
45
+ * import { PLASMIC } from "@/plasmic-init";
46
+ * import { ClientPlasmicRootProvider } from "@/plasmic-init-client"; // changed
47
+ * export default function MyPage() {
48
+ * const prefetchedData = await PLASMIC.fetchComponentData("YourPage");
49
+ * return (
50
+ * <ClientPlasmicRootProvider // don't pass in loader
51
+ * prefetchedData={prefetchedData}
52
+ * >
53
+ * {yourContent()}
54
+ * </ClientPlasmicRootProvider>;
55
+ * );
56
+ * }
57
+ * ```
58
+ */
59
+ export function ClientPlasmicRootProvider(
60
+ props
61
+ ) {
62
+ return (
63
+ <PlasmicRootProvider loader={PLASMIC} {...props}></PlasmicRootProvider>
64
+ );
65
+ }
@@ -1,4 +1,5 @@
1
- import { initPlasmicLoader } from "@plasmicapp/loader-nextjs";
1
+ import { initPlasmicLoader } from "@plasmicapp/loader-nextjs/react-server-conditional";
2
+ import * as NextNavigation from "next/navigation";
2
3
 
3
4
  export const PLASMIC = initPlasmicLoader({
4
5
  projects: [
@@ -13,13 +14,7 @@ export const PLASMIC = initPlasmicLoader({
13
14
  // project, allowing you to see your designs without publishing. Please
14
15
  // only use this for development, as this is significantly slower.
15
16
  preview: false,
16
- });
17
-
18
- // You can register any code components that you want to use here; see
19
- // https://docs.plasmic.app/learn/code-components-ref/
20
- // And configure your Plasmic project to use the host url pointing at
21
- // the /plasmic-host page of your nextjs app (for example,
22
- // http://localhost:3000/plasmic-host). See
23
- // https://docs.plasmic.app/learn/app-hosting/#set-a-plasmic-project-to-use-your-app-host
24
17
 
25
- // PLASMIC.registerComponent(...);
18
+ // Needed for Next.js app router support.
19
+ nextNavigation: NextNavigation,
20
+ });
@@ -0,0 +1,85 @@
1
+ import { PLASMIC } from "@/plasmic-init";
2
+ import { ClientPlasmicRootProvider } from "@/plasmic-init-client";
3
+ import { ComponentRenderData,PlasmicComponent } from "@plasmicapp/loader-nextjs";
4
+ import { Metadata, ResolvingMetadata } from "next";
5
+ import { notFound } from "next/navigation";
6
+
7
+ // Use revalidate if you want incremental static regeneration
8
+ export const revalidate = 60;
9
+ interface Params {
10
+ catchall: string[] | undefined;
11
+ }
12
+ export async function generateStaticParams(): Promise<Params[]> {
13
+ const pageModules = await PLASMIC.fetchPages();
14
+ return pageModules.map((mod) => {
15
+ const catchall =
16
+ mod.path === "/" ? undefined : mod.path.substring(1).split("/");
17
+ return {
18
+ catchall,
19
+ };
20
+ });
21
+ }
22
+ interface LoaderPageProps {
23
+ params: Promise<Params>;
24
+ }
25
+ export async function generateMetadata(
26
+ { params }: LoaderPageProps,
27
+ parent: ResolvingMetadata
28
+ ): Promise<Metadata> {
29
+ const { componentData } = await getPlasmicData(params);
30
+
31
+ if (!componentData) {
32
+ return parent as Promise<Metadata>;
33
+ }
34
+ const pageMeta = componentData.entryCompMetas[0];
35
+ const metadata = await PLASMIC.unstable__generateMetadata(componentData, {
36
+ params: pageMeta.params ?? {},
37
+ query: {},
38
+ });
39
+
40
+ return { ...(await parent), ...metadata };
41
+ }
42
+
43
+ export default async function PlasmicLoaderPage({
44
+ params,
45
+ }: LoaderPageProps) {
46
+ const { pagePath, componentData } = await getPlasmicData(params);
47
+
48
+ if (!componentData) {
49
+ notFound();
50
+ }
51
+ const pageMeta = componentData.entryCompMetas[0];
52
+ const prefetchedQueryData = await PLASMIC.unstable__getServerQueriesData(
53
+ componentData,
54
+ {
55
+ pagePath,
56
+ params: pageMeta.params,
57
+ query: {},
58
+ }
59
+ );
60
+
61
+ return (
62
+ <ClientPlasmicRootProvider
63
+ prefetchedData={componentData}
64
+ prefetchedQueryData={prefetchedQueryData}
65
+ pageParams={pageMeta.params}
66
+ pageRoute={pageMeta.path}
67
+ >
68
+ <PlasmicComponent component={pageMeta.displayName} />
69
+ </ClientPlasmicRootProvider>
70
+ );
71
+ }
72
+
73
+ async function getPlasmicData(
74
+ params: Promise<Params>
75
+ ): Promise<{ pagePath: string; componentData?: ComponentRenderData }> {
76
+ const catchall = (await params).catchall;
77
+ const pagePath = catchall ? `/${catchall.join("/")}` : "/";
78
+
79
+ const componentData = await PLASMIC.maybeFetchComponentData(pagePath);
80
+
81
+ if (!componentData || componentData.entryCompMetas.length === 0) {
82
+ return { pagePath };
83
+ }
84
+ return { pagePath, componentData };
85
+ }
@@ -0,0 +1,33 @@
1
+ import type { Metadata } from "next";
2
+ import localFont from "next/font/local";
3
+ import "./globals.css";
4
+
5
+ const geistSans = localFont({
6
+ src: "./fonts/GeistVF.woff",
7
+ variable: "--font-geist-sans",
8
+ weight: "100 900",
9
+ });
10
+ const geistMono = localFont({
11
+ src: "./fonts/GeistMonoVF.woff",
12
+ variable: "--font-geist-mono",
13
+ weight: "100 900",
14
+ });
15
+
16
+ export const metadata: Metadata = {
17
+ title: "Create Next App",
18
+ description: "Generated by create next app",
19
+ };
20
+
21
+ export default function RootLayout({
22
+ children,
23
+ }: Readonly<{
24
+ children: React.ReactNode;
25
+ }>) {
26
+ return (
27
+ <html lang="en">
28
+ <body className={`${geistSans.variable} ${geistMono.variable}`}>
29
+ {children}
30
+ </body>
31
+ </html>
32
+ );
33
+ }
@@ -0,0 +1,6 @@
1
+ import { PlasmicCanvasHost } from "@plasmicapp/loader-nextjs";
2
+ import "@/plasmic-init-client";
3
+
4
+ export default function PlasmicHost() {
5
+ return <PlasmicCanvasHost />;
6
+ }