├── .gitignore ├── .prettierignore ├── LICENSE ├── README.md ├── customtypes └── page │ ├── index.json │ └── mocks.json ├── documents ├── en-us │ ├── ZBHc0BAAACoAz4-X=#=ZKxS_hEAACQAcpfF=#=page=#=ZBHc0BAAACoAz4-Z=#=en-us=#=y.json │ └── ZBHedhAAAKdKz5Kp=#=ZL5Q7BEAACIAKwCg=#=page=#=ZBHedhAAACsAz5Kr=#=en-us=#=y.json └── index.json ├── eslint.config.mjs ├── next.config.ts ├── package-lock.json ├── package.json ├── prismicio-types.d.ts ├── slicemachine.config.json ├── src ├── app │ ├── [uid] │ │ └── page.tsx │ ├── api │ │ ├── exit-preview │ │ │ └── route.ts │ │ ├── preview │ │ │ └── route.ts │ │ └── revalidate │ │ │ └── route.ts │ ├── icon.png │ ├── layout.tsx │ ├── page.tsx │ └── slice-simulator │ │ └── page.tsx ├── prismicio.ts └── slices │ ├── RichText │ ├── index.module.css │ ├── index.tsx │ ├── mocks.json │ └── model.json │ └── index.ts └── tsconfig.json /.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.* 7 | .yarn/* 8 | !.yarn/patches 9 | !.yarn/plugins 10 | !.yarn/releases 11 | !.yarn/versions 12 | 13 | # testing 14 | /coverage 15 | 16 | # next.js 17 | /.next/ 18 | /out/ 19 | 20 | # production 21 | /build 22 | 23 | # misc 24 | .DS_Store 25 | *.pem 26 | 27 | # debug 28 | npm-debug.log* 29 | yarn-debug.log* 30 | yarn-error.log* 31 | .pnpm-debug.log* 32 | 33 | # env files (can opt-in for committing if needed) 34 | .env* 35 | 36 | # vercel 37 | .vercel 38 | 39 | # typescript 40 | *.tsbuildinfo 41 | next-env.d.ts 42 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | .slicemachine 2 | .next -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Prismic + Next.js Minimal Starter 2 | 3 | Want to quickly get started building your own project with [Prismic][prismic] and [Next.js][nextjs]? This project includes basic configurations and nothing else. The project includes one Rich Text slice, a homepage, and a dynamic page. 4 | 5 | - **Demo**: [Open live demo][live-demo] 6 | - **Learn more about Prismic and Next.js**: [Prismic Next.js Documentation][prismic-docs] 7 | 8 |   9 | 10 | ![Website screenshot](https://user-images.githubusercontent.com/31219208/228821412-fdde92b2-c13c-4287-b799-611fa96a5fd6.png) 11 | 12 |   13 | 14 | ## 🚀 Quick Start 15 | 16 | To start a new project using this starter: 17 | 18 | 1. Visit . 19 | 2. Create a new Prismic repository by selecting **Next.js**. 20 | 3. Select the **Minimal starter**. 21 | 4. Fill out your repository details and continue with the steps given in Prismic. 22 | 23 | When you're ready to start your project, run the following command: 24 | 25 | ```sh 26 | npm run dev 27 | ``` 28 | 29 | ## How to use your project 30 | 31 | To edit the content of this project, go to [prismic.io/dashboard](https://prismic.io/dashboard), click on the repository for this website, and start editing. 32 | 33 | ### Create a page 34 | 35 | To create a page, click on the green pencil icon, then select **Page**. 36 | 37 | Pages are made of Slices. You can add and rearrange Slices to your pages. 38 | 39 | Your new page will be accessible by its URL, but it won't appear on the website automatically. To let users discover it, add it to the navigation. 40 | 41 | ### Preview documents 42 | 43 | If you chose this starter when you created a new repository from the Prismic Dashboard, then your repository is preconfigured with previews on localhost. To change the preview configuration or add previews to your production or staging environments, see [Preview Drafts in Next.js](https://prismic.io/docs/technologies/preview-content-nextjs) in the Prismic documentation. 44 | 45 | ### Customize this website 46 | 47 | This website is preconfigured with Prismic. It has three Prismic packages installed: 48 | 49 | - `@prismicio/client` provides helpers for fetching content from Prismic 50 | - `@prismicio/react` provides React components for rendering content from Prismic 51 | - `@prismicio/next` provides a wrapper component to configure Prismic previews 52 | 53 | These packages are already integrated and employed in this app. Take a look at the code to see how they're used. 54 | 55 | ### Edit the code 56 | 57 | There are two steps to rendering content from Prismic in your Next.js project: 58 | 59 | 1. Fetch content from the Prismic API using `@prismicio/client`. 60 | 2. Template the content using components from `@prismicio/react`. 61 | 62 | Here are some of the files in your project that you can edit: 63 | 64 | - `prismicio.ts` - This file includes configuration for `@prismicio/client` and exports useful API helpers. 65 | - `app/layout.tsx` - This is your layout component, which includes configuration for `@prismicio/react` and `@prismicio/next`. 66 | - `app/page.tsx` - This is the app homepage. It queries and renders a page document with the UID (unique identifier) "home" from the Prismic API. 67 | - `app/[uid]/page.tsx` - This is the page component, which queries and renders a page document from your Prismic repository based on the UID. 68 | - `slices/*/index.tsx` - Each Slice in your project has an index.tsx file that renders the Slice component. Edit this file to customize your Slices. 69 | 70 | These are important files that you should leave as-is: 71 | 72 | - `app/api/exit-preview/route.ts` - Do not edit or delete this file. This is the API endpoint to close a Prismic preview session. 73 | - `app/api/preview/route.ts` - Do not edit or delete this file. This is the API endpoint to launch a Prismic preview session. 74 | - `app/slice-simulator/page.tsx` - Do not edit or delete this file. This file simulates your Slice components in development. 75 | - `slices/` - This directory contains Slice components, which are generated programmatically by Slice Machine. To customize a Slice template, you can edit the Slice's index.tsx file. To add Slices, delete Slices, or edit Slice models, use Slice Machine (more info below). 76 | 77 | Learn more about how to edit your components with [Fetch Data in Next.js](https://prismic.io/docs/technologies/fetch-data-nextjs) and [Template Content in Next.js](https://prismic.io/docs/technologies/template-content-nextjs). 78 | 79 | Learn more about how to use [TypeScript with Prismic](https://prismic.io/docs/typescript-nextjs). 80 | 81 | ### Deploy to the web 82 | 83 | To put your project online, see [Deploy your Next.js App](https://prismic.io/docs/technologies/deploy-nextjs). 84 | 85 | ### Edit content models with Slice Machine 86 | 87 | This project includes an application called Slice Machine, which generates models for your Custom Types and Slices. Slice Machine stores the models locally in your codebase, so you can save and version them. It also syncs your models to Prismic. To learn how to use Slice Machine, read [Model Content in Next.js](https://prismic.io/docs/technologies/model-content-nextjs). 88 | 89 | If you change or add to your Custom Types, you'll need to update your route handling to match. To learn how to do that, read [Define Paths in Next.js](https://prismic.io/docs/technologies/define-paths-nextjs). 90 | 91 | ## Documentation 92 | 93 | For the official Prismic documentation, see [Prismic's guide for Next.js][prismic-docs] or the [technical references for the installed Prismic packages](https://prismic.io/docs/technologies/technical-references). 94 | 95 | ## License 96 | 97 | ``` 98 | Copyright 2013-2022 Prismic (https://prismic.io) 99 | 100 | Licensed under the Apache License, Version 2.0 (the "License"); 101 | you may not use this file except in compliance with the License. 102 | You may obtain a copy of the License at 103 | 104 | http://www.apache.org/licenses/LICENSE-2.0 105 | 106 | Unless required by applicable law or agreed to in writing, software 107 | distributed under the License is distributed on an "AS IS" BASIS, 108 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 109 | See the License for the specific language governing permissions and 110 | limitations under the License. 111 | ``` 112 | 113 | [prismic]: https://prismic.io/ 114 | [prismic-docs]: https://prismic.io/docs/technologies/nextjs 115 | [prismic-sign-up]: https://prismic.io/dashboard/signup 116 | [nextjs]: https://nextjs.org/ 117 | [live-demo]: https://nextjs-starter-prismic-minimal.vercel.app/ 118 | -------------------------------------------------------------------------------- /customtypes/page/index.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "page", 3 | "label": "Page", 4 | "format": "page", 5 | "repeatable": true, 6 | "status": true, 7 | "json": { 8 | "Main": { 9 | "uid": { 10 | "type": "UID", 11 | "config": { 12 | "label": "UID", 13 | "placeholder": "" 14 | } 15 | }, 16 | "title": { 17 | "type": "StructuredText", 18 | "config": { 19 | "label": "Title", 20 | "placeholder": "", 21 | "allowTargetBlank": true, 22 | "single": "heading1" 23 | } 24 | }, 25 | "slices": { 26 | "type": "Slices", 27 | "fieldset": "Slice Zone", 28 | "config": { 29 | "choices": { 30 | "rich_text": { 31 | "type": "SharedSlice" 32 | } 33 | } 34 | } 35 | } 36 | }, 37 | "SEO & Metadata": { 38 | "meta_title": { 39 | "type": "Text", 40 | "config": { 41 | "label": "Meta Title", 42 | "placeholder": "A title of the page used for social media and search engines" 43 | } 44 | }, 45 | "meta_description": { 46 | "type": "Text", 47 | "config": { 48 | "label": "Meta Description", 49 | "placeholder": "A brief summary of the page" 50 | } 51 | }, 52 | "meta_image": { 53 | "type": "Image", 54 | "config": { 55 | "label": "Meta Image", 56 | "constraint": { 57 | "width": 2400, 58 | "height": 1260 59 | }, 60 | "thumbnails": [] 61 | } 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /customtypes/page/mocks.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "uid": { 4 | "__TYPE__": "UIDContent", 5 | "value": "congress" 6 | }, 7 | "title": { 8 | "__TYPE__": "StructuredTextContent", 9 | "value": [ 10 | { 11 | "type": "heading1", 12 | "content": { 13 | "text": "Medicine" 14 | } 15 | } 16 | ] 17 | }, 18 | "slices": { 19 | "__TYPE__": "SliceContentType", 20 | "value": [ 21 | { 22 | "key": "rich_text$3e97d0df-9e9e-40c8-83ff-346f91aba429", 23 | "name": "rich_text", 24 | "widget": { 25 | "__TYPE__": "SharedSliceContent", 26 | "variation": "default", 27 | "primary": { 28 | "content": { 29 | "__TYPE__": "StructuredTextContent", 30 | "value": [ 31 | { 32 | "type": "paragraph", 33 | "content": { 34 | "text": "Aliquip veniam sit excepteur excepteur ut laborum exercitation duis incididunt." 35 | } 36 | } 37 | ] 38 | } 39 | }, 40 | "items": [ 41 | { 42 | "__TYPE__": "GroupItemContent", 43 | "value": [] 44 | } 45 | ] 46 | } 47 | } 48 | ] 49 | } 50 | } 51 | ] 52 | -------------------------------------------------------------------------------- /documents/en-us/ZBHc0BAAACoAz4-X=#=ZKxS_hEAACQAcpfF=#=page=#=ZBHc0BAAACoAz4-Z=#=en-us=#=y.json: -------------------------------------------------------------------------------- 1 | {"uid":"home","title":[{"type":"heading1","content":{"text":"Homepage","spans":[]}}],"slices":[{"key":"rich_text$d9f37f2b-0bb9-4898-aaf6-e9c35ac6e72a","value":{"variation":"default","items":[{}],"primary":{"content":[{"type":"heading1","content":{"text":"Welcome to your new website!","spans":[]}},{"type":"paragraph","content":{"text":"Here are five things you should know in order to get started:","spans":[]}},{"type":"list-item","content":{"text":"All content in your website is rendered with Slices. You currently have one RichText Slice, which you can find in your project at slices/RichText/.","spans":[{"start":130,"end":146,"type":"label","data":"codespan"}]}},{"type":"list-item","content":{"text":"You can create more Slices by opening Slice Machine at http://localhost:9999.","spans":[{"start":55,"end":76,"type":"hyperlink","data":{"preview":{"title":"http://localhost:9999/"},"url":"http://localhost:9999/","target":"_blank"}}]}},{"type":"list-item","content":{"text":"This website has a homepage (pages/index.js) and a dynamic page (pages/[uid].js). The dynamic page will render pages with dynamic URLs, like this one.","spans":[{"start":29,"end":44,"type":"label","data":"codespan"},{"start":65,"end":79,"type":"label","data":"codespan"},{"start":141,"end":149,"type":"hyperlink","data":{"id":"ZBHedhAAAKdKz5Kp","preview":{"title":"Another Page"},"wioUrl":"wio://documents/ZBHedhAAAKdKz5Kp"}}]}},{"type":"list-item","content":{"text":"You can edit these pages and create new ones, by opening your Page Builder from prismic.io/dashboard.","spans":[{"start":80,"end":100,"type":"hyperlink","data":{"preview":{"title":"https://prismic.io/dashboard"},"url":"https://prismic.io/dashboard","target":"_blank"}}]}},{"type":"list-item","content":{"text":"You can find lots more information about how to develop your project (including how to deploy it) in the Prismic Next.js documentation.","spans":[{"start":105,"end":134,"type":"hyperlink","data":{"preview":{"title":"https://prismic.io/docs/nextjs"},"url":"https://prismic.io/docs/nextjs","target":"_blank"}}]}}]}}}],"meta_description":"The homepage of your new website.","meta_image":{"origin":{"id":"ZKxRnhEAACIAcpFB","url":"https://prismic-io.s3.amazonaws.com/nextjs-starter-prismic-minimal/1ef1c411-4d12-4f07-af9e-a510683d8be7_cody-silver-eKB9CoaIUDo-unsplash.jpg","width":1920,"height":1023},"provider":"imgix","url":"https://images.prismic.io/nextjs-starter-prismic-minimal/1ef1c411-4d12-4f07-af9e-a510683d8be7_cody-silver-eKB9CoaIUDo-unsplash.jpg?auto=compress,format&rect=0,7,1920,1008&w=2400&h=1260","alt":null,"credits":null,"width":2400,"height":1260,"edit":{"zoom":1.25,"crop":{"x":0,"y":-9},"background":"#fff"},"thumbnails":{}},"meta_title":"Homepage","uid_TYPE":"UID","uid_POSITION":0,"title_TYPE":"StructuredText","title_POSITION":1,"slices_TYPE":"Slices","slices_POSITION":2,"slices.rich_text_TYPE":"SharedSlice","slices.rich_text_POSITION":3,"slices.rich_text.variations.default.primary.content_TYPE":"StructuredText","slices.rich_text.variations.default.primary.content_POSITION":4,"meta_description_TYPE":"Text","meta_description_POSITION":5,"meta_image_TYPE":"Image","meta_image_POSITION":6,"meta_title_TYPE":"Text","meta_title_POSITION":7,"slugs_INTERNAL":["homepage","homepage-edit"],"uids_INTERNAL":["home"]} -------------------------------------------------------------------------------- /documents/en-us/ZBHedhAAAKdKz5Kp=#=ZL5Q7BEAACIAKwCg=#=page=#=ZBHedhAAACsAz5Kr=#=en-us=#=y.json: -------------------------------------------------------------------------------- 1 | {"uid":"another-page","title":[{"type":"heading1","content":{"text":"Another Page","spans":[]}}],"slices":[{"key":"rich_text$c84cd334-7a7d-4915-b4ec-9af129daed3d","value":{"variation":"default","items":[{}],"primary":{"content":[{"type":"heading1","content":{"text":"Another Page","spans":[]}},{"type":"paragraph","content":{"text":"Welcome to your other page.","spans":[]}},{"type":"paragraph","content":{"text":"Go back to the homepage.","spans":[{"start":0,"end":23,"type":"hyperlink","data":{"id":"ZBHc0BAAACoAz4-X","preview":{"title":"Homepage"},"wioUrl":"wio://documents/ZBHc0BAAACoAz4-X"}}]}}]}}}],"meta_description":"Another page on your website.","meta_title":"Another Page","meta_image":{"origin":{"id":"Xs0bIhIAACMAWMj4","url":"https://prismic-io.s3.amazonaws.com/slicemachine-blank/dcea6535-f43b-49a7-8623-bf281aaf1cb2_roller-skating.png","width":2048,"height":1536},"provider":"imgix","url":"https://images.prismic.io/slicemachine-blank/dcea6535-f43b-49a7-8623-bf281aaf1cb2_roller-skating.png?auto=compress,format&rect=0,230,2048,1075&w=2400&h=1260","alt":"A person","credits":null,"width":2400,"height":1260,"edit":{"zoom":1.171875,"crop":{"x":0,"y":-270},"background":"transparent"},"thumbnails":{}},"uid_TYPE":"UID","uid_POSITION":0,"title_TYPE":"StructuredText","title_POSITION":1,"slices_TYPE":"Slices","slices_POSITION":2,"slices.rich_text_TYPE":"SharedSlice","slices.rich_text_POSITION":3,"slices.rich_text.variations.default.primary.content_TYPE":"StructuredText","slices.rich_text.variations.default.primary.content_POSITION":4,"meta_title_TYPE":"Text","meta_title_POSITION":5,"meta_description_TYPE":"Text","meta_description_POSITION":6,"meta_image_TYPE":"Image","meta_image_POSITION":7,"slugs_INTERNAL":["another-page"],"uids_INTERNAL":["another-page"]} -------------------------------------------------------------------------------- /documents/index.json: -------------------------------------------------------------------------------- 1 | {"signature":"d822909da36f7334dce8b348475edb2248ef5add"} -------------------------------------------------------------------------------- /eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import { dirname } from "path"; 2 | import { fileURLToPath } from "url"; 3 | import { FlatCompat } from "@eslint/eslintrc"; 4 | 5 | const __filename = fileURLToPath(import.meta.url); 6 | const __dirname = dirname(__filename); 7 | 8 | const compat = new FlatCompat({ 9 | baseDirectory: __dirname, 10 | }); 11 | 12 | const eslintConfig = [ 13 | ...compat.extends("next/core-web-vitals", "next/typescript"), 14 | ]; 15 | 16 | export default eslintConfig; 17 | -------------------------------------------------------------------------------- /next.config.ts: -------------------------------------------------------------------------------- 1 | import type { NextConfig } from "next"; 2 | 3 | const nextConfig: NextConfig = { 4 | /* config options here */ 5 | }; 6 | 7 | export default nextConfig; 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nextjs-starter-prismic-minimal", 3 | "version": "0.1.0", 4 | "private": true, 5 | "license": "Apache-2.0", 6 | "author": "Prismic (https://prismic.io)", 7 | "scripts": { 8 | "dev": "concurrently \"npm:next:dev\" \"npm:slicemachine\" --names \"next,slicemachine\" --prefix-colors blue,magenta", 9 | "next:dev": "next dev --turbopack", 10 | "build": "next build", 11 | "start": "next start", 12 | "lint": "next lint", 13 | "slicemachine": "start-slicemachine", 14 | "format": "prettier --write ." 15 | }, 16 | "dependencies": { 17 | "@prismicio/client": "^7.15.1", 18 | "@prismicio/next": "^2.0.0", 19 | "@prismicio/react": "^3.0.0", 20 | "next": "^15.1.6", 21 | "react": "^19.0.0", 22 | "react-dom": "^19.0.0" 23 | }, 24 | "devDependencies": { 25 | "@eslint/eslintrc": "^3.2.0", 26 | "@slicemachine/adapter-next": "^0.3.66", 27 | "@types/node": "^22.13.0", 28 | "@types/react": "^19.0.8", 29 | "@types/react-dom": "^19.0.3", 30 | "concurrently": "^9.1.2", 31 | "eslint": "^9.19.0", 32 | "eslint-config-next": "^15.1.6", 33 | "slice-machine-ui": "^2.12.3", 34 | "typescript": "^5.7.3" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /prismicio-types.d.ts: -------------------------------------------------------------------------------- 1 | // Code generated by Slice Machine. DO NOT EDIT. 2 | 3 | import type * as prismic from "@prismicio/client"; 4 | 5 | type Simplify = { [KeyType in keyof T]: T[KeyType] }; 6 | 7 | type PageDocumentDataSlicesSlice = RichTextSlice; 8 | 9 | /** 10 | * Content for Page documents 11 | */ 12 | interface PageDocumentData { 13 | /** 14 | * Title field in *Page* 15 | * 16 | * - **Field Type**: Title 17 | * - **Placeholder**: *None* 18 | * - **API ID Path**: page.title 19 | * - **Tab**: Main 20 | * - **Documentation**: https://prismic.io/docs/field#rich-text-title 21 | */ 22 | title: prismic.TitleField; 23 | 24 | /** 25 | * Slice Zone field in *Page* 26 | * 27 | * - **Field Type**: Slice Zone 28 | * - **Placeholder**: *None* 29 | * - **API ID Path**: page.slices[] 30 | * - **Tab**: Main 31 | * - **Documentation**: https://prismic.io/docs/field#slices 32 | */ 33 | slices: prismic.SliceZone /** 34 | * Meta Title field in *Page* 35 | * 36 | * - **Field Type**: Text 37 | * - **Placeholder**: A title of the page used for social media and search engines 38 | * - **API ID Path**: page.meta_title 39 | * - **Tab**: SEO & Metadata 40 | * - **Documentation**: https://prismic.io/docs/field#key-text 41 | */; 42 | meta_title: prismic.KeyTextField; 43 | 44 | /** 45 | * Meta Description field in *Page* 46 | * 47 | * - **Field Type**: Text 48 | * - **Placeholder**: A brief summary of the page 49 | * - **API ID Path**: page.meta_description 50 | * - **Tab**: SEO & Metadata 51 | * - **Documentation**: https://prismic.io/docs/field#key-text 52 | */ 53 | meta_description: prismic.KeyTextField; 54 | 55 | /** 56 | * Meta Image field in *Page* 57 | * 58 | * - **Field Type**: Image 59 | * - **Placeholder**: *None* 60 | * - **API ID Path**: page.meta_image 61 | * - **Tab**: SEO & Metadata 62 | * - **Documentation**: https://prismic.io/docs/field#image 63 | */ 64 | meta_image: prismic.ImageField; 65 | } 66 | 67 | /** 68 | * Page document from Prismic 69 | * 70 | * - **API ID**: `page` 71 | * - **Repeatable**: `true` 72 | * - **Documentation**: https://prismic.io/docs/custom-types 73 | * 74 | * @typeParam Lang - Language API ID of the document. 75 | */ 76 | export type PageDocument = 77 | prismic.PrismicDocumentWithUID, "page", Lang>; 78 | 79 | export type AllDocumentTypes = PageDocument; 80 | 81 | /** 82 | * Primary content in *RichText → Primary* 83 | */ 84 | export interface RichTextSliceDefaultPrimary { 85 | /** 86 | * Content field in *RichText → Primary* 87 | * 88 | * - **Field Type**: Rich Text 89 | * - **Placeholder**: Lorem ipsum... 90 | * - **API ID Path**: rich_text.primary.content 91 | * - **Documentation**: https://prismic.io/docs/field#rich-text-title 92 | */ 93 | content: prismic.RichTextField; 94 | } 95 | 96 | /** 97 | * Default variation for RichText Slice 98 | * 99 | * - **API ID**: `default` 100 | * - **Description**: RichText 101 | * - **Documentation**: https://prismic.io/docs/slice 102 | */ 103 | export type RichTextSliceDefault = prismic.SharedSliceVariation< 104 | "default", 105 | Simplify, 106 | never 107 | >; 108 | 109 | /** 110 | * Slice variation for *RichText* 111 | */ 112 | type RichTextSliceVariation = RichTextSliceDefault; 113 | 114 | /** 115 | * RichText Shared Slice 116 | * 117 | * - **API ID**: `rich_text` 118 | * - **Description**: RichText 119 | * - **Documentation**: https://prismic.io/docs/slice 120 | */ 121 | export type RichTextSlice = prismic.SharedSlice< 122 | "rich_text", 123 | RichTextSliceVariation 124 | >; 125 | 126 | declare module "@prismicio/client" { 127 | interface CreateClient { 128 | ( 129 | repositoryNameOrEndpoint: string, 130 | options?: prismic.ClientConfig, 131 | ): prismic.Client; 132 | } 133 | 134 | namespace Content { 135 | export type { 136 | PageDocument, 137 | PageDocumentData, 138 | PageDocumentDataSlicesSlice, 139 | AllDocumentTypes, 140 | RichTextSlice, 141 | RichTextSliceDefaultPrimary, 142 | RichTextSliceVariation, 143 | RichTextSliceDefault, 144 | }; 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /slicemachine.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "repositoryName": "nextjs-starter-prismic-minimal", 3 | "adapter": "@slicemachine/adapter-next", 4 | "libraries": ["./src/slices"], 5 | "localSliceSimulatorURL": "http://localhost:3000/slice-simulator", 6 | "apiEndpoint": "" 7 | } 8 | -------------------------------------------------------------------------------- /src/app/[uid]/page.tsx: -------------------------------------------------------------------------------- 1 | import { Metadata } from "next"; 2 | import { notFound } from "next/navigation"; 3 | 4 | import { asText, filter } from "@prismicio/client"; 5 | import { SliceZone } from "@prismicio/react"; 6 | 7 | import { createClient } from "@/prismicio"; 8 | import { components } from "@/slices"; 9 | 10 | type Params = { uid: string }; 11 | 12 | export default async function Page({ params }: { params: Promise }) { 13 | const { uid } = await params; 14 | const client = createClient(); 15 | const page = await client.getByUID("page", uid).catch(() => notFound()); 16 | 17 | // renders the page's slices. 18 | return ; 19 | } 20 | 21 | export async function generateMetadata({ 22 | params, 23 | }: { 24 | params: Promise; 25 | }): Promise { 26 | const { uid } = await params; 27 | const client = createClient(); 28 | const page = await client.getByUID("page", uid).catch(() => notFound()); 29 | 30 | return { 31 | title: asText(page.data.title), 32 | description: page.data.meta_description, 33 | openGraph: { 34 | title: page.data.meta_title ?? undefined, 35 | images: [{ url: page.data.meta_image.url ?? "" }], 36 | }, 37 | }; 38 | } 39 | 40 | export async function generateStaticParams() { 41 | const client = createClient(); 42 | 43 | // Get all pages from Prismic, except the homepage. 44 | const pages = await client.getAllByType("page", { 45 | filters: [filter.not("my.page.uid", "home")], 46 | }); 47 | 48 | return pages.map((page) => ({ uid: page.uid })); 49 | } 50 | -------------------------------------------------------------------------------- /src/app/api/exit-preview/route.ts: -------------------------------------------------------------------------------- 1 | import { exitPreview } from "@prismicio/next"; 2 | 3 | /** 4 | * This endpoint exits a preview session. 5 | */ 6 | export function GET() { 7 | return exitPreview(); 8 | } 9 | -------------------------------------------------------------------------------- /src/app/api/preview/route.ts: -------------------------------------------------------------------------------- 1 | import { NextRequest } from "next/server"; 2 | import { redirectToPreviewURL } from "@prismicio/next"; 3 | 4 | import { createClient } from "@/prismicio"; 5 | 6 | /** 7 | * This endpoint handles previews that are launched from the Page Builder. 8 | */ 9 | export async function GET(request: NextRequest) { 10 | const client = createClient(); 11 | 12 | return await redirectToPreviewURL({ client, request }); 13 | } 14 | -------------------------------------------------------------------------------- /src/app/api/revalidate/route.ts: -------------------------------------------------------------------------------- 1 | import { NextResponse } from "next/server"; 2 | import { revalidateTag } from "next/cache"; 3 | 4 | /** 5 | * This endpoint purges Prismic content from Next.js' cache. It is called when 6 | * content is published in Prismic. 7 | */ 8 | export async function POST() { 9 | revalidateTag("prismic"); 10 | 11 | return NextResponse.json({ revalidated: true, now: Date.now() }); 12 | } 13 | -------------------------------------------------------------------------------- /src/app/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prismicio-community/nextjs-starter-prismic-minimal/eb3d45e9b34bdbbe8468e52af7e4bcba859fe8ee/src/app/icon.png -------------------------------------------------------------------------------- /src/app/layout.tsx: -------------------------------------------------------------------------------- 1 | import { PrismicPreview } from "@prismicio/next"; 2 | import { repositoryName } from "@/prismicio"; 3 | 4 | export default function RootLayout({ 5 | children, 6 | }: Readonly<{ 7 | children: React.ReactNode; 8 | }>) { 9 | return ( 10 | 11 | {children} 12 | 13 | 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /src/app/page.tsx: -------------------------------------------------------------------------------- 1 | import { type Metadata } from "next"; 2 | 3 | import { asText } from "@prismicio/client"; 4 | import { SliceZone } from "@prismicio/react"; 5 | 6 | import { createClient } from "@/prismicio"; 7 | import { components } from "@/slices"; 8 | 9 | export default async function Home() { 10 | const client = createClient(); 11 | const home = await client.getByUID("page", "home"); 12 | 13 | // renders the page's slices. 14 | return ; 15 | } 16 | 17 | export async function generateMetadata(): Promise { 18 | const client = createClient(); 19 | const home = await client.getByUID("page", "home"); 20 | 21 | return { 22 | title: asText(home.data.title), 23 | description: home.data.meta_description, 24 | openGraph: { 25 | title: home.data.meta_title ?? undefined, 26 | images: [{ url: home.data.meta_image.url ?? "" }], 27 | }, 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /src/app/slice-simulator/page.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | SliceSimulator, 3 | SliceSimulatorParams, 4 | getSlices, 5 | } from "@slicemachine/adapter-next/simulator"; 6 | import { SliceZone } from "@prismicio/react"; 7 | 8 | import { components } from "@/slices"; 9 | 10 | export default async function SliceSimulatorPage({ 11 | searchParams, 12 | }: SliceSimulatorParams) { 13 | const { state } = await searchParams; 14 | const slices = getSlices(state); 15 | 16 | return ( 17 | 18 | 19 | 20 | ); 21 | } 22 | -------------------------------------------------------------------------------- /src/prismicio.ts: -------------------------------------------------------------------------------- 1 | import { 2 | createClient as baseCreateClient, 3 | ClientConfig, 4 | Route, 5 | } from "@prismicio/client"; 6 | import { enableAutoPreviews } from "@prismicio/next"; 7 | import sm from "../slicemachine.config.json"; 8 | 9 | /** 10 | * The project's Prismic repository name. 11 | */ 12 | export const repositoryName = 13 | process.env.NEXT_PUBLIC_PRISMIC_ENVIRONMENT || sm.repositoryName; 14 | 15 | /** 16 | * The project's Prismic route resolvers. This list determines a Prismic document's URL. 17 | */ 18 | const routes: Route[] = [ 19 | { type: "page", uid: "home", path: "/" }, 20 | { type: "page", path: "/:uid" }, 21 | ]; 22 | 23 | /** 24 | * Creates a Prismic client for the project's repository. The client is used to 25 | * query content from the Prismic API. 26 | * 27 | * @param config - Configuration for the Prismic client. 28 | */ 29 | export function createClient(config: ClientConfig = {}) { 30 | const client = baseCreateClient(sm.apiEndpoint || repositoryName, { 31 | routes, 32 | fetchOptions: 33 | process.env.NODE_ENV === "production" 34 | ? { next: { tags: ["prismic"] }, cache: "force-cache" } 35 | : { next: { revalidate: 5 } }, 36 | ...config, 37 | }); 38 | 39 | enableAutoPreviews({ client }); 40 | 41 | return client; 42 | } 43 | -------------------------------------------------------------------------------- /src/slices/RichText/index.module.css: -------------------------------------------------------------------------------- 1 | .richtext { 2 | max-width: 600px; 3 | margin: 6em auto; 4 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, 5 | Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; 6 | } 7 | -------------------------------------------------------------------------------- /src/slices/RichText/index.tsx: -------------------------------------------------------------------------------- 1 | import { type FC } from "react"; 2 | import { type Content } from "@prismicio/client"; 3 | import { PrismicNextLink } from "@prismicio/next"; 4 | import { 5 | PrismicRichText, 6 | type SliceComponentProps, 7 | type JSXMapSerializer, 8 | } from "@prismicio/react"; 9 | import styles from "./index.module.css"; 10 | 11 | const components: JSXMapSerializer = { 12 | hyperlink: ({ node, children }) => { 13 | return {children}; 14 | }, 15 | label: ({ node, children }) => { 16 | if (node.data.label === "codespan") { 17 | return {children}; 18 | } 19 | }, 20 | }; 21 | 22 | /** 23 | * Props for `RichText`. 24 | */ 25 | type RichTextProps = SliceComponentProps; 26 | 27 | /** 28 | * Component for "RichText" Slices. 29 | */ 30 | const RichText: FC = ({ slice }) => { 31 | return ( 32 |
33 | 34 |
35 | ); 36 | }; 37 | 38 | export default RichText; 39 | -------------------------------------------------------------------------------- /src/slices/RichText/mocks.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "__TYPE__": "SharedSliceContent", 4 | "variation": "default", 5 | "primary": { 6 | "content": { 7 | "__TYPE__": "StructuredTextContent", 8 | "value": [ 9 | { 10 | "type": "paragraph", 11 | "content": { 12 | "text": "Esse aliqua qui in qui duis nisi. Esse elit elit culpa cillum dolore eiusmod aliquip deserunt." 13 | } 14 | } 15 | ] 16 | } 17 | }, 18 | "items": [ 19 | { 20 | "__TYPE__": "GroupItemContent", 21 | "value": [] 22 | } 23 | ] 24 | } 25 | ] 26 | -------------------------------------------------------------------------------- /src/slices/RichText/model.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "rich_text", 3 | "type": "SharedSlice", 4 | "name": "RichText", 5 | "description": "RichText", 6 | "variations": [ 7 | { 8 | "id": "default", 9 | "name": "Default", 10 | "docURL": "...", 11 | "version": "sktwi1xtmkfgx8626", 12 | "description": "RichText", 13 | "primary": { 14 | "content": { 15 | "type": "StructuredText", 16 | "config": { 17 | "label": "Content", 18 | "placeholder": "Lorem ipsum...", 19 | "allowTargetBlank": true, 20 | "multi": "paragraph,preformatted,heading1,heading2,heading3,strong,em,hyperlink,embed,list-item", 21 | "labels": ["codespan"] 22 | } 23 | } 24 | }, 25 | "items": {}, 26 | "imageUrl": "https://images.prismic.io/slice-machine/621a5ec4-0387-4bc5-9860-2dd46cbc07cd_default_ss.png?auto=compress,format" 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /src/slices/index.ts: -------------------------------------------------------------------------------- 1 | // Code generated by Slice Machine. DO NOT EDIT. 2 | 3 | import dynamic from "next/dynamic"; 4 | 5 | export const components = { 6 | rich_text: dynamic(() => import("./RichText")), 7 | }; 8 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2017", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "noEmit": true, 9 | "esModuleInterop": true, 10 | "module": "esnext", 11 | "moduleResolution": "bundler", 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "jsx": "preserve", 15 | "incremental": true, 16 | "plugins": [ 17 | { 18 | "name": "next" 19 | } 20 | ], 21 | "paths": { 22 | "@/*": ["./src/*"] 23 | } 24 | }, 25 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], 26 | "exclude": ["node_modules"] 27 | } 28 | --------------------------------------------------------------------------------