{"id":18309,"date":"2025-10-17T10:33:46","date_gmt":"2025-10-17T08:33:46","guid":{"rendered":"https:\/\/pagepro.co\/blog\/?p=18309"},"modified":"2025-11-06T13:09:19","modified_gmt":"2025-11-06T12:09:19","slug":"sanity-and-nextjs-for-ci-cd","status":"publish","type":"post","link":"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/","title":{"rendered":"Sanity and Nextjs for CI \/ CD"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"sanity-and-next-js-for-seamless-ci-cd-a-guide\">Sanity and Next.js for Seamless CI\/CD: A Guide<\/h2>\n\n\n\n<p>In development, optimizing workflows for efficiency is crucial, not only for internal processes but also for improving the end-user experience. CI\/CD (Continuous Integration and Continuous Delivery) plays a pivotal role in achieving these goals by <strong>automating testing, accelerating deployment, and allowing teams to deliver updates and features more rapidly.<\/strong> Combining <a href=\"https:\/\/pagepro.co\/services\/sanity-development\" target=\"_blank\" rel=\"noreferrer noopener\">Sanity<\/a> as a flexible headless CMS with <a href=\"https:\/\/pagepro.co\/services\/nextjs-development\" target=\"_blank\" rel=\"noreferrer noopener\">Next.js<\/a> as a powerful web framework creates a dynamic setup, giving developers precise control and speeding up project iterations. Here\u2019s how to integrate Sanity Nextjs CI\/CD to streamline your process and deliver a smoother, faster experience for your users.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"why-choose-sanity-and-next-js-for-your-projects\">Why Choose Sanity and Next.js for Your Projects?<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"a-perfect-pair-sanity-and-next-js\"><span class=\"underline-accent\">A Perfect Pair: Sanity and Next.js<\/span><\/h3>\n\n\n\n<p>Sanity and Next.js work perfectly together to <strong>create an efficient, high-performing workflow<\/strong> for content-driven applications. Sanity provides a flexible, headless CMS where content is easily managed, while Next.js serves as a powerful framework for fast and optimized web applications. <\/p>\n\n\n\n<p>Using Incremental Static Regeneration (ISR) in Next.js, you can set up static site generation that <strong>updates specific pages whenever new content is created or modified in Sanity,<\/strong> reducing the need for full rebuilds. The synergy allows you to quickly serve updated content with minimal impact on performance, creating a smoother experience for your users.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"sanity-a-headless-cms-built-for-flexibility\"><span class=\"underline-accent\">Sanity: A Headless CMS Built for Flexibility<\/span><\/h3>\n\n\n\n<p>Sanity is a top-tier headless CMS content management system, offering developers and editors <strong>both full control and flexibility.<\/strong> The latest Sanity Studio v3 introduces a rich editorial experience, where creators can simply click on UI elements to open and edit corresponding fields, making content updates intuitive and efficient. <\/p>\n\n\n\n<p>Developers also have full customization options, from default structures to custom tabs and logic, <strong>allowing the Studio to be precisely tailored to project needs.<\/strong> High-level of flexibility is a standout advantage, making Sanity a preferred choice for building scalable and adaptable content management solutions.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"next-js-speed-and-control-for-modern-web-development\"><span class=\"underline-accent\">Next.js: Speed and Control for Modern Web Development<\/span><\/h3>\n\n\n\n<p>Next.js has become one of the most popular frameworks for <strong>building fast, high-quality web applications.<\/strong> Its flexibility includes granular control over page load speeds and rendering options, along with powerful tools like middlewares and API routes. <\/p>\n\n\n\n<p>With ISR, Next.js allows you to generate static pages that update dynamically, combining the performance benefits of static sites with the flexibility of real-time data updates. For developers, Next.js <strong>represents a balance between speed, control, and ease of use,<\/strong> making it ideal for projects where performance and scalability are priorities.<\/p>\n\n\n\n<p>Learn how to optimize performance in Next.js from our CEO and CTO: <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.youtube.com\/watch?v=gAFLL1ZxrF4\"><img decoding=\"async\" loading=\"lazy\" width=\"630\" height=\"355\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-30-at-09.58.19.png\" alt=\"\" class=\"wp-image-18310\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-30-at-09.58.19.png 630w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-30-at-09.58.19-300x170.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-30-at-09.58.19-500x282.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/Screenshot-2024-10-30-at-09.58.19-324x183.png 324w\" sizes=\"(max-width: 630px) 100vw, 630px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ci-cd-with-sanity-and-next-js-speed-up-development-and-delivery\">CI\/CD with Sanity and Next.js: Speed Up Development and Delivery<\/h2>\n\n\n\n<p>CI\/CD &#8211; Continuous integration and Continuous&nbsp;Deployment\/Delivery is essential for streamlining the testing and delivery process, <strong>allowing for faster iterations and reducing manual workload. <\/strong>Below, we\u2019ll walk through setting up CI\/CD for a Next.js project integrated with Sanity, showcasing a solution to accelerate development and ensure smooth, efficient deployment.<\/p>\n\n\n\n<div class=\"wp-block-code-mind-cta c-cta-block\" style=\"background-color:#00141F;color:#FFFFFF\"><div class=\"c-cta-block__content\"><p class=\"c-cta-block__title\">Wondering if Sanity and Next.js are a good pick for your project?<\/p><div class=\"c-cta-block__action\"><a href=\"https:\/\/pagepro.co\/contact\" class=\"c-cta-block__button ga-cta ga-cta-consultation theme-bg-3\">Ask our experts<\/a><\/div><\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"setting-up-sanity\">Setting Up Sanity<\/h2>\n\n\n\n<p>Sanity Studio is the central admin panel for managing all your content and editorial workflows. And we will focus on it during this process. It\u2019s fully customizable,<strong> allowing you to define and style the interface from code<\/strong> to fit your project\u2019s specific needs. You can choose from a variety of configurations, from default structures to adding custom tabs and logic for a tailored experience.<\/p>\n\n\n\n<p>For an in-depth guide on customization options, visit the <a href=\"https:\/\/www.sanity.io\/docs\/structure-builder-introduction\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Sanity Structure Builder documentation<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"639\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image21-1024x639.png\" alt=\"Sanity Studio in Sanity Nextjs CI CD\" class=\"wp-image-18331\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image21-1024x639.png 1024w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image21-300x187.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image21-768x479.png 768w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image21-500x312.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image21-324x202.png 324w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image21.png 1520w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>With Sanity Studio, you have two hosting options:<\/p>\n\n\n\n<ol>\n<li><strong>Host on Sanity Cloud<\/strong>: This option is ideal if you want to manage content across multiple applications or don\u2019t need Studio hosted directly on your domain. In this setup, Sanity Studio is hosted separately, and you\u2019ll need a dedicated repository for it.<\/li>\n\n\n\n<li><strong>Self-Host within Your Application<\/strong>: If your content is specific to one application, you can embed Sanity Studio directly within your Next js&nbsp;app. This means you can host Studio on a custom route like <code>\/sanity-studio<\/code>, making it a seamless part of your application\u2019s codebase.<\/li>\n<\/ol>\n\n\n<div class=\"c-newsletter-sendgrid-wrapper js-newsletter-sendgrid-wrapper ga-filedownload-viewed\">\n    <div class=\"c-newsletter-sendgrid\">\n                    <p class=\"c-newsletter-sendgrid__title\">\n                Get Next.js Vercel Cost Optimization Guide            <\/p>\n        \n         \n            <p class=\"c-newsletter-sendgrid__description\">\n                Learn real-life techniques to optimize the hosting costs of your Next.js apps.            <\/p>\n        \n        <form action=\"\" class=\"c-newsletter-sendgrid__form f-form js-newsletter-sendgrid\" data-key=\"e60f07b6-7b2d-4939-88db-8a4715700f39\">\n            <div class=\"c-newsletter-sendgrid__form-mail\">\n                <label class=\"c-label\" for=\"newsletter_email\">Company E-mail address<\/label>\n                <input class=\"c-input js-newsletter-sendgrid-email\" type=\"email\" id=\"newsletter_email\" required>\n                <input class=\"c-newsletter-sendgrid__button ga-cta-filedownload\" type=\"submit\" value=\"Download\">\n            <\/div>\n            <div class=\"c-newsletter-sendgrid__form-consent\">\n                                                        <input class=\"c-checkbox js-newsletter-consent\" type=\"checkbox\" name=\"newsletter_consent\" id=\"newsletter_consent_1\" required>\n                    <label class=\"c-label\" for=\"newsletter_consent_1\">I accept the Privacy Policy and agree to process my personal data by Pagepro for marketing purposes.<\/label>\n                            <\/div>\n        <\/form>\n\n        <div class=\"c-newsletter-sendgrid__cover-container\">\n                            <img decoding=\"async\" class=\"c-newsletter-sendgrid__cover-1\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2025\/04\/Cover-1.jpg\" alt=\"Cover of a guide titled NEXT.JS VERCEL COST OPTIMISATION GUIDE by Jakub Dakowicz and Chris Lojniewski, featuring insights on self-hosting Nextjs, with a red geometric background and Pagepro logo in the top left corner.\" >\n                                            <\/div>\n\n        <div class=\"c-newsletter-sendgrid__popup-wrapper js-newsletter-sendgrid-popup is-hidden\">\n            <div class=\"c-newsletter-sendgrid__popup\">\n                <div class=\"c-newsletter-sendgrid__popup-icon\">\n                    <svg width=\"140\" height=\"140\" viewBox=\"0 0 140 140\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                    <g clip-path=\"url(#clip0_6621_2135)\">\n                    <path d=\"M65.625 100.625C65.625 109.908 69.3125 118.81 75.8763 125.374C82.44 131.938 91.3424 135.625 100.625 135.625C109.908 135.625 118.81 131.938 125.374 125.374C131.938 118.81 135.625 109.908 135.625 100.625C135.625 91.3424 131.938 82.44 125.374 75.8763C118.81 69.3125 109.908 65.625 100.625 65.625C91.3424 65.625 82.44 69.3125 75.8763 75.8763C69.3125 82.44 65.625 91.3424 65.625 100.625Z\" stroke=\"#0A2B3D\" stroke-width=\"8.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/>\n                    <path d=\"M116.223 90.4517L99.2774 113.044C98.9005 113.545 98.4206 113.959 97.8701 114.259C97.3196 114.558 96.7113 114.737 96.0862 114.781C95.461 114.826 94.8335 114.736 94.246 114.518C93.6584 114.3 93.1244 113.959 92.6799 113.517L83.9299 104.767\" stroke=\"#0A2B3D\" stroke-width=\"8.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/>\n                    <path d=\"M48.125 91.875H13.125C10.8044 91.875 8.57876 90.9531 6.93782 89.3122C5.29687 87.6712 4.375 85.4456 4.375 83.125V13.125C4.375 10.8044 5.29687 8.57876 6.93782 6.93782C8.57876 5.29687 10.8044 4.375 13.125 4.375H118.125C120.446 4.375 122.671 5.29687 124.312 6.93782C125.953 8.57876 126.875 10.8044 126.875 13.125V52.5\" stroke=\"#0A2B3D\" stroke-width=\"8.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/>\n                    <path d=\"M124.898 7.5835L77.3909 44.1235C74.0176 46.7185 69.881 48.1255 65.625 48.1255C61.3691 48.1255 57.2325 46.7185 53.8592 44.1235L6.35254 7.5835\" stroke=\"#0A2B3D\" stroke-width=\"8.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/>\n                    <\/g>\n                    <defs>\n                    <clipPath id=\"clip0_6621_2135\">\n                    <rect width=\"140\" height=\"140\" fill=\"white\"\/>\n                    <\/clipPath>\n                    <\/defs>\n                    <\/svg>\n                <\/div>\n                                    <p class=\"c-newsletter-sendgrid__popup-text\">\n                        Thank you for signing up. Check your e-mail for the guide.                    <\/p>\n                                <div class=\"c-newsletter-sendgrid__popup-action\">\n                    <button class=\"c-newsletter-sendgrid__button c-newsletter-sendgrid__button--full-width js-newsletter-sendgrid-popup-close\">Close<\/button>\n                <\/div>\n            <\/div>\n        <\/div>\n    <\/div>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"hosting-on-sanity-cloud-step-by-step\"><span class=\"underline-accent\">Hosting on Sanity Cloud &#8211; Step by Step<\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"1-create-a-new-sanity-project\">1. Create a New Sanity Project: <\/h4>\n\n\n\n<ul>\n<li>Create an account if you don\u2019t have one in Sanity.<\/li>\n\n\n\n<li>Create a new project:&nbsp;<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"725\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image6-1024x725.png\" alt=\"New project in Sanity Nextjs CI CD\" class=\"wp-image-18316\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image6-1024x725.png 1024w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image6-300x212.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image6-768x544.png 768w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image6-472x334.png 472w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image6-324x229.png 324w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image6.png 1328w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul>\n<li>For simplicity we can select \u201cQuickstart with schema\u201d&nbsp; so we will have some initial schemas at start.<\/li>\n\n\n\n<li>Select Marketing site with page builder and click Deploy Studio<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"996\" height=\"1024\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image24-996x1024.png\" alt=\"Quickstart in Sanity Nextjs CI CD\" class=\"wp-image-18334\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image24-996x1024.png 996w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image24-292x300.png 292w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image24-768x790.png 768w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image24-325x334.png 325w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image24-1024x1053.png 1024w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image24-324x333.png 324w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image24.png 1266w\" sizes=\"(max-width: 996px) 100vw, 996px\" \/><\/figure>\n\n\n\n<p>Thats it! Your studio is deployed and ready to work. Now let\u2019s create a repository for this code and setup the CI\/CD to keep this studio up to date!<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"2-connecting-sanity-to-github\">2. Connecting Sanity to GitHub<\/h4>\n\n\n\n<ul>\n<li>Initialize a new repository on GitHub&nbsp;<\/li>\n\n\n\n<li>Sign in to Sanity using CLI just typing &#8220;`<code>sanity login<\/code>&#8220;` in your console and log to your account<\/li>\n\n\n\n<li>Initialize the sanity project: <\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code-mind-code c-code\"><code class=\"javascript\">npm create sanity@latest -- --quickstart {projectId}<\/code><\/pre>\n\n\n\n<ul>\n<li>Follow up with the configuration.<\/li>\n\n\n\n<li>Create an env file and put your details there:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code-mind-code c-code\"><code class=\"javascript\">SANITY_STUDIO_PROJECT_ID=your_project_id_here\nSANITY_STUDIO_DATASET=production\n<\/code><\/pre>\n\n\n\n<ul>\n<li>Update your <code>sanity.cli<\/code> and <code>sanity.config.ts<\/code> files to use env variables instead of hardcoded values<\/li>\n<\/ul>\n\n\n\n<p>Your <code>sanity.cli<\/code> should look like this:<\/p>\n\n\n\n<pre class=\"wp-block-code-mind-code c-code\"><code class=\"javascript\">import {defineCliConfig} from 'sanity\/cli'\n\n\nexport default defineCliConfig({\n api: {\n   projectId: process.env.SANITY_STUDIO_PROJECT_ID,\n   dataset: process.env.SANITY_STUDIO_DATASET,\n },\n})\n<\/code><\/pre>\n\n\n\n<p>And here&#8217;s how <code>sanity.config.ts<\/code> should look like:<\/p>\n\n\n\n<pre class=\"wp-block-code-mind-code c-code\"><code class=\"javascript\">import {defineConfig} from 'sanity'\nimport {structureTool} from 'sanity\/structure'\nimport {visionTool} from '@sanity\/vision'\nimport {schemaTypes} from '.\/schemaTypes'\n\n\nexport default defineConfig({\n name: 'default',\n title: 'Test project',\n projectId: process.env.SANITY_STUDIO_PROJECT_ID || '',\n dataset: process.env.SANITY_STUDIO_DATASET || '',\n\n\n plugins: [structureTool(), visionTool()],\n\n\n schema: {\n   types: schemaTypes,\n },\n})\n<\/code><\/pre>\n\n\n\n<p>Now go to the <a href=\"https:\/\/www.sanity.io\/manage\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Sanity management<\/a> and select your project and go to the API tab. Click on <strong>Add New Token<\/strong> button and select <strong>Deploy Studio<\/strong> option.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"564\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image20-1024x564.png\" alt=\"\" class=\"wp-image-18330\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image20-1024x564.png 1024w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image20-300x165.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image20-768x423.png 768w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image20-1536x845.png 1536w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image20-500x275.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image20-324x178.png 324w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image20.png 1868w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Go to GitHub repository and add a secret with this token: <em>Settings &gt; Secrets And variables &gt; Actions &gt; New secret<\/em>. Remember to <code>add projectID<\/code> and dataset variables at this point.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"577\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image8-1024x577.png\" alt=\"\" class=\"wp-image-18318\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image8-1024x577.png 1024w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image8-300x170.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image8-768x433.png 768w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image8-1536x866.png 1536w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image8-500x282.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image8-324x183.png 324w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image8.png 1902w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Add workflow for GitHub actions in your code. Create a <code>.github\/workflows\/sanity.yml<\/code> file in root of your project and put this content inside:&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code-mind-code c-code\"><code class=\"javascript\">name: Deploy Sanity action\n\n\non:\n push:\n   branches: [main]\n\n\njobs:\n deploy:\n   runs-on: ubuntu-latest\n   steps:\n     - name: Checkout code\n       uses: actions\/checkout@v4\n     - name: Set up Node.js\n       uses: actions\/setup-node@v4\n       with:\n         cache: npm\n         node-version: lts\/*\n     - name: Install dependencies\n       run: npm ci\n  \n     - name: Deploy Sanity Studio\n       env:\n         SANITY_AUTH_TOKEN: ${{ secrets.SANITY_AUTH_TOKEN }}\n         SANITY_STUDIO_PROJECT_ID: ${{ secrets.SANITY_STUDIO_PROJECT_ID }}\n         SANITY_STUDIO_DATASET: ${{ secrets.SANITY_STUDIO_DATASET }}\n       run: |\n         npm install -g @sanity\/cli\n         sanity login --token $SANITY_AUTH_TOKEN\n         sanity deploy --non-interactive\n<\/code><\/pre>\n\n\n\n<p>It\u2019s a very simple workflow that will just install all required dependencies and run 2 commands <code>sanity login<\/code> using the token from secrets and <code>sanity deploy<\/code> to deploy the studio. This workflow will be triggered on any pushes to the main branches. <\/p>\n\n\n\n<p>It will use the <code>sanity.ci.ts<\/code> file to get the project configuration, which is why we need to add these 2 extra secrets (PROJECT_ID &amp; DATASET). Now you can update your schemas, push the code, and see if it works correctly.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"421\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image14-1024x421.png\" alt=\"\" class=\"wp-image-18324\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image14-1024x421.png 1024w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image14-300x123.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image14-768x315.png 768w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image14-1536x631.png 1536w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image14-500x205.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image14-324x133.png 324w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image14.png 1999w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>You can find a code for this solution here: <a href=\"https:\/\/github.com\/Pagepro\/sanity-ci\">https:\/\/github.com\/Pagepro\/sanity-ci<\/a><\/p>\n\n\n\n<div class=\"c-newsletter-block-acf\">\n    <p class=\"c-newsletter-block-acf__title c-newsletter__header\">\n        EXPERT INSIGHTS, FRICTIONLESSLY DELIVERED!    <\/p>\n    <p class=\"c-newsletter-block-acf__desc c-newsletter__header\">\n        Curated tech news delivered straight to your inbox every month.    <\/p>\n    <form method=\"post\" class=\"c-newsletter-block-acf__form js-newsletter-form c-newsletter__action\" name=\"newsletter-block-form\">\n        <input name=\"newsletter-email\" id=\"newsletter-email\" type=\"text\" class=\"c-newsletter-block-acf__input js-newsletter-input\" placeholder=\"Company Email\" \/>\n        <input name=\"newsletter-campaign\" id=\"newsletter-campaign\" type=\"hidden\" value=\"\" \/>\n        <div class=\"c-newsletter-block-acf__group\">\n            <input name=\"consent\" id=\"consent\" type=\"checkbox\" class=\"js-newsletter-consent\" \/>\n            <label class=\"c-newsletter-block-acf__label\" for=\"consent\">I accept the <a href=\"https:\/\/pagepro.co\/privacy-policy\">Privacy Policy<\/a> and agree to process my personal data by Pagepro for marketing purposes.<\/label>\n        <\/div>\n        <input type=\"submit\" class=\"c-newsletter-block-acf__button button js-newsletter-sub ga-newsletter-form-content\" value=\"Sign up\" \/>\n        <p class=\"theme-size-1 js-message-valid is-hidden is-invalid\"><\/p>\n    <\/form>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"setting-up-next-js\">Setting Up Next.js<\/h2>\n\n\n\n<p>If you decide to go with self-hosted studio inside of your Nextjs app we need to start with creating a Nextjs project.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"creating-a-new-next-js-project\"><span class=\"underline-accent\">Creating a New Next.js Project<\/span><\/h3>\n\n\n\n<p>You can use any existing project if you want &#8211; if you will use your existing project you can skip this step<\/p>\n\n\n\n<p>Start by creating a new project by typing this in your terminal:<\/p>\n\n\n\n<pre class=\"wp-block-code-mind-code c-code\"><code class=\"javascript\">npx create-next-app@latest<\/code><\/pre>\n\n\n\n<p>Follow the setup and you should be ready to go. Next, create a new repository in GitHub and add origin to your new project.<\/p>\n\n\n\n<pre class=\"wp-block-code-mind-code c-code\"><code class=\"javascript\">git remote add origin git@github.com:yourpath\/sanity-next-ci.git\n\ngit branch -M main\n\ngit push -u origin main<\/code><\/pre>\n\n\n\n<p>Now we have a project that we can use in our Vercel account. Let\u2019s start from that step.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"configuring-cd-with-vercel\">Configuring CD with Vercel<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"introduction-to-vercel\"><span class=\"underline-accent\">Introduction to Vercel<\/span><\/h3>\n\n\n\n<p>Vercel is a cloud platform that enables developers to deploy, scale, and manage web applications with ease. It specializes in hosting Jamstack applications, such as those built with Next.js, and provides automatic deployments and optimization for performance. Vercel integrates seamlessly with GitHub automatically deploying code changes and offering both preview and production environments.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"connecting-github-repository-to-vercel\"><span class=\"underline-accent\">Connecting GitHub Repository to Vercel<\/span><\/h3>\n\n\n\n<p>To setup CI\/CD for our Nextjs app on Vercel we just need to connect our repository to Vercel and follow a few quick steps:<\/p>\n\n\n\n<ul>\n<li>Create an account and a project in Vercel. Connect Vercel &amp; GitHub so we can select one of our repositories and then find your repository and click the <strong>Import <\/strong>button:<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"692\" height=\"241\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image17.png\" alt=\"\" class=\"wp-image-18327\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image17.png 692w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image17-300x104.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image17-500x174.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image17-324x113.png 324w\" sizes=\"(max-width: 692px) 100vw, 692px\" \/><\/figure>\n\n\n\n<ul>\n<li>Select your repository with the NextJS app. In the configuration select Next.js as a framework so it will prefill the build and output settings for us.<\/li>\n\n\n\n<li>If you want to customize the build process open the build and output settings and you can change the command or root directory of your project.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"411\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image10-1024x411.png\" alt=\"\" class=\"wp-image-18320\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image10-1024x411.png 1024w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image10-300x120.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image10-768x308.png 768w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image10-500x201.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image10-324x130.png 324w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image10.png 1265w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>If everything is ok just click the <strong>Deploy<\/strong> button. You can watch the progress now and get familiar with the logs, or we can jump to the next section in the meantime. On a successful deploy, you should be able to see the project&#8217;s URL and check the deployment.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"720\" height=\"442\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image7.png\" alt=\"\" class=\"wp-image-18317\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image7.png 720w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image7-300x184.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image7-500x307.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image7-324x199.png 324w\" sizes=\"(max-width: 720px) 100vw, 720px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"735\" height=\"816\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image15.png\" alt=\"\" class=\"wp-image-18325\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image15.png 735w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image15-270x300.png 270w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image15-301x334.png 301w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image15-324x360.png 324w\" sizes=\"(max-width: 735px) 100vw, 735px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"automatic-deployments\"><span class=\"underline-accent\">Automatic Deployments<\/span><\/h3>\n\n\n\n<p>Vercel will now automatically build &amp; deploy your main branch every time you push any changes to it. You can add your own domain or use the Vercel ones.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"add-sanity-studio-to-our-nextjs-project\">Add Sanity Studio to our Nextjs project<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"set-up-sanity-within-your-project\"><span class=\"underline-accent\">Set Up Sanity Within Your Project<\/span><\/h3>\n\n\n\n<p>There are a few ways to <a href=\"https:\/\/www.sanity.io\/docs\/embedding-sanity-studio\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">embed the studio<\/a>, but we will use the simplest one.<\/p>\n\n\n\n<p>Start by installing <code>next-sanity<\/code> package <code>npm i next-sanity sanity<\/code>. Then create a <code>env<\/code> file in the root of the project and add these variables:<\/p>\n\n\n\n<pre class=\"wp-block-code-mind-code c-code\"><code class=\"javascript\">NEXT_PUBLIC_SANITY_PROJECT_ID=your_id_here\nNEXT_PUBLIC_SANITY_DATASET=production\n<\/code><\/pre>\n\n\n\n<p>Create a new file in your <code>app<\/code> directory <code>\/admin\/[[...index]]\/page.tsx<\/code> and add this code:<\/p>\n\n\n\n<pre class=\"wp-block-code-mind-code c-code\"><code class=\"javascript\">\"use client\";\n\n\nimport { defineConfig } from \"sanity\";\nimport { structureTool } from \"sanity\/structure\";\nimport { NextStudio } from \"next-sanity\/studio\";\nimport { schemaTypes } from \"..\/..\/schemaTypes\";\n\n\nconst sanityConfig = defineConfig({\n title: \"Sanity CI\/CD test\",\n projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,\n dataset: process.env.NEXT_PUBLIC_SANITY_DATASET,\n apiVersion: \"2024-04-23\",\n basePath: \"\/admin\",\n plugins: [structureTool()],\n schema: {\n   types: schemaTypes,\n },\n});\n\n\nexport default function AdminPage() {\n return &lt;NextStudio config={sanityConfig} \/>;\n}\n<\/code><\/pre>\n\n\n\n<p>For simplicity, copy the schemaTypes from the previous project and paste it into the <code>src\/app<\/code> directory. The project structure should look like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"323\" height=\"395\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image16.png\" alt=\"schemaTypes\" class=\"wp-image-18326\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image16.png 323w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image16-245x300.png 245w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image16-273x334.png 273w\" sizes=\"(max-width: 323px) 100vw, 323px\" \/><\/figure>\n\n\n\n<p>Now run the project in development mode <code>npm run dev<\/code>. If you followed my instructions you should see this screen on the <a href=\"http:\/\/localhost:3000\/admin\">http:\/\/localhost:3000\/admin<\/a> URL<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"894\" height=\"368\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image4.png\" alt=\"URL\" class=\"wp-image-18314\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image4.png 894w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image4-300x123.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image4-768x316.png 768w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image4-500x206.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image4-324x133.png 324w\" sizes=\"(max-width: 894px) 100vw, 894px\" \/><\/figure>\n\n\n\n<p>To get rid of it<span style=\"box-sizing: border-box; margin: 0px; padding: 0px;\">, we need to go to the sanity dashboard API &gt; CORS origins. Click on&nbsp;<strong>Add Cors<\/strong>&nbsp;origin and make sure you select \u201callow credentials\u201d, as it\u2019s required for the studio. After that,<\/span> you should be able to see your studio now.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"470\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image3-2-1024x470.png\" alt=\"CORS origins\" class=\"wp-image-18313\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image3-2-1024x470.png 1024w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image3-2-300x138.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image3-2-768x353.png 768w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image3-2-1536x705.png 1536w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image3-2-500x230.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image3-2-324x149.png 324w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image3-2.png 1999w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"436\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image18-1024x436.png\" alt=\"CORS origins cont'd\" class=\"wp-image-18328\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image18-1024x436.png 1024w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image18-300x128.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image18-768x327.png 768w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image18-1536x653.png 1536w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image18-500x213.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image18-324x138.png 324w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image18.png 1890w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>You will also have to follow the Cors instructions with the Vercel domain. But now, let\u2019s adjust our Vercel configuration to handle the studio.<\/p>\n\n\n\n<p>So, we have a Sanity studio set up in the local environment. Let\u2019s update our Vercel so we have a CI\/CD process ready. Go to Vercel, select your project, click on the <strong>Settings tab,<\/strong> and select <strong>Environment Variables<\/strong> from the left:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"574\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image22-1024x574.png\" alt=\"Project Settings\" class=\"wp-image-18332\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image22-1024x574.png 1024w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image22-300x168.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image22-768x430.png 768w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image22-1536x860.png 1536w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image22-500x280.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image22-324x181.png 324w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image22.png 1562w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Create a new env variable with the same names as in our .env file : <code>NEXT_PUBLIC_SANITY_PROJECT_ID &amp; NEXT_PUBLIC_SANITY_DATASET<\/code>.<\/p>\n\n\n\n<div class=\"wp-block-code-mind-cta c-cta-block\" style=\"background-color:#00141F;color:#FFFFFF\"><div class=\"c-cta-block__content\"><p class=\"c-cta-block__title\">hINT<\/p><p class=\"c-cta-block__description\">You can copy content of .env file and just paste it here in first Key position, and it will automatically create all of your env variables for you.<\/p><\/div><\/div>\n\n\n\n<p>Now it should look like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"948\" height=\"633\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image5.png\" alt=\"View\n\n\" class=\"wp-image-18315\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image5.png 948w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image5-300x200.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image5-768x513.png 768w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image5-500x334.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image5-324x216.png 324w\" sizes=\"(max-width: 948px) 100vw, 948px\" \/><\/figure>\n\n\n\n<p>Click the <strong>Save button<\/strong> and they should appear at the bottom.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"1013\" height=\"261\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image13.png\" alt=\"Variables\" class=\"wp-image-18323\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image13.png 1013w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image13-300x77.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image13-768x198.png 768w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image13-500x129.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image13-324x83.png 324w\" sizes=\"(max-width: 1013px) 100vw, 1013px\" \/><\/figure>\n\n\n\n<p>Now we are ready to go. If you didn\u2019t push your changes with Studio, it\u2019s a good time to test it! If you already did, update anything in our code (add some text on the homepage) and push the changes. We should see that we\u2019ve triggered the build process.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"972\" height=\"368\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image1-1.png\" alt=\"Deployments\" class=\"wp-image-18312\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image1-1.png 972w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image1-1-300x114.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image1-1-768x291.png 768w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image1-1-500x189.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image1-1-324x123.png 324w\" sizes=\"(max-width: 972px) 100vw, 972px\" \/><\/figure>\n\n\n\n<p>It should throw an error as we have a <code>page.ts file<\/code> in our schemaTypes directory:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"431\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image23-1024x431.png\" alt=\"Error\n\" class=\"wp-image-18333\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image23-1024x431.png 1024w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image23-300x126.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image23-768x323.png 768w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image23-500x210.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image23-324x136.png 324w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image23.png 1250w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>It\u2019s a sample of the error log. We just need to rename this file to anything else like <code>pageType.tx<\/code> or move it to a different directory as <code>page.ts<\/code> name is dedicated to routes in Nextjs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"advanced-ci-cd-configurations\">Advanced CI\/CD Configurations<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"custom-logic-in-the-ci-runtime\"><span class=\"underline-accent\">Custom Logic in the CI Runtime<\/span><\/h3>\n\n\n\n<p>In Vercel, you can change the build command to your own script that will first call some linting stage, then trigger tests, and finally build the application.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"937\" height=\"304\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image19.png\" alt=\"Build and development in Sanity Nextjs CI\/CD\" class=\"wp-image-18329\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image19.png 937w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image19-300x97.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image19-768x249.png 768w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image19-500x162.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image19-324x105.png 324w\" sizes=\"(max-width: 937px) 100vw, 937px\" \/><\/figure>\n\n\n\n<p>In GitHub actions (it\u2019s part of the dlow) add the steps that you want and they will be executed one by one.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"handling-environment-variables\"><span class=\"underline-accent\">Handling Environment Variables<\/span><\/h3>\n\n\n\n<p>Vercel allows setting the variables for all or specific branches. When you create a new variable, you can select the Production, Development, or Preview branch. In Previe,w you can even specify the exact branch name you want to use, it\u2019s very flexible.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"948\" height=\"569\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image9.png\" alt=\"Environment Variables in Sanity Nextjs CI\/CD\" class=\"wp-image-18319\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image9.png 948w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image9-300x180.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image9-768x461.png 768w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image9-500x300.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image9-324x194.png 324w\" sizes=\"(max-width: 948px) 100vw, 948px\" \/><\/figure>\n\n\n\n<p>For GitHub actions, it\u2019s a little bit more complicated, as you have a few paths to follow. You can conditionally access secrets based on the branch using if conditions.<\/p>\n\n\n\n<pre class=\"wp-block-code-mind-code c-code\"><code class=\"javascript\">- name: Deploy the app\n     if: github.ref == 'refs\/heads\/main'  # Only use secrets on the 'main' branch\n     run: deploy.sh\n     env:\n       API_KEY: ${{ secrets.API_KEY }}\n<\/code><\/pre>\n\n\n\n<p>You can restrict workflows to run only on specific branches.<\/p>\n\n\n\n<pre class=\"wp-block-code-mind-code c-code\"><code class=\"javascript\">on:\n push:\n   branches:\n     - main  # Only trigger the workflow on the 'main' branch\n<\/code><\/pre>\n\n\n\n<p>Use environments to manage secrets that are tied to specific workflows and set these environments in your pipeline<\/p>\n\n\n\n<pre class=\"wp-block-code-mind-code c-code\"><code class=\"javascript\">jobs:\n deploy:\n   runs-on: ubuntu-latest\n   environment: production  # Use production environment secrets<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"663\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image11-1024x663.png\" alt=\"Configure production in Sanity Nextjs CI\/CD\" class=\"wp-image-18321\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image11-1024x663.png 1024w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image11-300x194.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image11-768x497.png 768w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image11-500x324.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image11-324x210.png 324w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image11.png 1287w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"branch-deployments\"><span class=\"underline-accent\">Branch Deployments<\/span><\/h3>\n\n\n\n<p>To set up different branches in GitHub actions like <strong>production\/staging\/development <\/strong>you can create separate workflows (remember to use correct <code>env<\/code> variables for specific environments) or add all of them here:<\/p>\n\n\n\n<pre class=\"wp-block-code-mind-code c-code\"><code class=\"javascript\">on:\n push:\n   branches:\n     - main \n     - staging \n     - development  <\/code><\/pre>\n\n\n\n<p>For Vercel <strong>all branches<\/strong> are automatically deployed as <strong>Preview Deployments<\/strong> when pushed to GitHub, making it easy to test your changes on staging\/preview deployment. Preview deployment is using your <code>env<\/code> variables set to preview branches (or main ones if you didn\u2019t set them specifically).&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"monitoring-and-alerts\"><span class=\"underline-accent\">Monitoring and Alerts<\/span><\/h3>\n\n\n\n<p>If your CI\/CD fails either on the Vercel or GitHub actions, you will see it in the dashboard. If you have your email notifications on, you should also receive an email about it. In the logs, you can see exactly which steps were successful and which ones failed. Here&#8217;s an example of  GitHub actions log:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"606\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image12-1024x606.png\" alt=\"GitHub actions log in Sanity Nextjs CI\/CD\" class=\"wp-image-18322\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image12-1024x606.png 1024w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image12-300x177.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image12-768x454.png 768w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image12-500x296.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image12-324x192.png 324w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image12.png 1532w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Example Vercel log:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"466\" src=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image2-1-1024x466.png\" alt=\"Vercel log in Sanity Nextjs CI\/CD\" class=\"wp-image-18311\" srcset=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image2-1-1024x466.png 1024w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image2-1-300x136.png 300w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image2-1-768x349.png 768w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image2-1-500x227.png 500w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image2-1-324x147.png 324w, https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2024\/10\/image2-1.png 1256w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"best-practices-and-tips\">Best Practices and Tips<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"optimizing-build-times\"><span class=\"underline-accent\">Optimizing Build Times<\/span><\/h3>\n\n\n\n<p>By default, actions are run in fresh virtual environments, so in a way, they start from scratch. However, you can use caching to save time. For example, when building a project or running tests, certain files (like dependencies) <strong>don\u2019t need to be downloaded every time<\/strong>. You can cache these files between workflow runs to speed up future runs.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"security-considerations\"><span class=\"underline-accent\">Security Considerations<\/span><\/h3>\n\n\n\n<p>Like in our example,<strong> you should always hide your variables from exposure<\/strong>. GitHub provides encrypted secrets to store sensitive data, such as API tokens. These secrets can be accessed within workflows but remain hidden in logs and are protected. In our example, we are using secrets for the project ID, dataset, and auth token instead of hardcoding them in the workflow file. The same thing for Vercel &#8211; they are not visible in the logs and are not exposed to users.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>As you see, setting up CI\/CD for Sanity or NextJS app is very easy. You only need an hour <strong>to save at least 20 hours during development<\/strong> and performing everything manually.<\/p>\n\n\n\n<p>Once you get familiar with the basics, you can build your own custom GitHub actions that will match your criteria for CI\/CD. Almost everything that you can do manually can be automated &#8211; you just need to generate a token to get access or add some extra code to handle the scenario.<\/p>\n\n\n\n<p>I highly recommend using AI as a personal helper. You ask ChatGPT or Cursor to write a workflow for you. Describe what you need, and it should generate the code for you. With the help of documentation, you can make it work, and it\u2019s even easier than writing it from scratch.<\/p>\n\n\n\n<div class=\"wp-block-code-mind-cta c-cta-block\" style=\"background-color:#00141F;color:#FFFFFF\"><div class=\"c-cta-block__content\"><p class=\"c-cta-block__title\">Ready to start using Sanity and Next.js?<\/p><div class=\"c-cta-block__action\"><a href=\"https:\/\/pagepro.co\/contact\" class=\"c-cta-block__button ga-cta ga-cta-consultation theme-bg-3\">We&#8217;re here to help<\/a><\/div><\/div><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"resources\">Resources<\/h2>\n\n\n\n<ul>\n<li><a href=\"https:\/\/vercel.com\/docs\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">https:\/\/vercel.com\/docs<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/docs.github.com\/en\/actions\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">https:\/\/docs.github.com\/en\/actions<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.sanity.io\/docs\/deployment\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">https:\/\/www.sanity.io\/docs\/deployment<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"read-more\">Read More<\/h2>\n\n\n\n<ul>\n<li><a href=\"https:\/\/pagepro.co\/blog\/5-lessons-for-next-js-performance-optimization-in-large-projects\/\" target=\"_blank\" rel=\"noreferrer noopener\">5 Lessons For Next js Performance Optimization in Large Projects<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pagepro.co\/blog\/how-to-use-next-js-static-site-generator\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Use Next.js for Static Site Generation (SSG)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pagepro.co\/blog\/nextjs-performance-optimization-in-9-steps\/\" target=\"_blank\" rel=\"noreferrer noopener\">Nextjs Performance Optimization in 9 Steps<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pagepro.co\/blog\/sanity-spring-release-2025-6-ways-sanity-empowers-teams\/\" target=\"_blank\" rel=\"noreferrer noopener\">Sanity Spring Release 2025: 6 Ways Sanity Empowers Teams<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pagepro.co\/blog\/what-is-sanity\/\" target=\"_blank\" rel=\"noreferrer noopener\">What is Sanity.io: 2025 Guide<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"faq\">FAQ<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"what-is-ci-cd\"><span class=\"underline-accent\">What is CI\/CD?<\/span><\/h3>\n\n\n\n<p>CI\/CD stands for <strong>Continuous Integration &amp; Continuous Deployment <\/strong>(or sometimes <strong>Delivery<\/strong>). It automates testing, builds, and deployment, reducing manual work and speeding up release cycles.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"is-ci-cd-different-from-devops\"><span class=\"underline-accent\">Is CI\/CD Different from DevOps?<\/span><\/h3>\n\n\n\n<p>Yes, CI\/CD is one of the tools or workflows used within DevOps to achieve faster, more consistent software delivery. It automates building, testing, and deploying code changes. DevOps, meanwhile, is a culture and set of practices that combine development and operations.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"what-are-some-ci-cd-pipeline-examples\"><span class=\"underline-accent\">What Are Some CI\/CD Pipeline Examples?<\/span><\/h3>\n\n\n\n<p>Some popular examples of CI\/CD pipelines are:<\/p>\n\n\n\n<ul>\n<li><strong>GitHub Actions<\/strong>: Often used for automating Next.js and Sanity deployments, integrating directly with Vercel or Netlify.<\/li>\n\n\n\n<li><strong>GitLab CI\/CD<\/strong>:&nbsp; Provides built-in pipelines triggered by commits, suitable for both frontend and backend workflows.<\/li>\n\n\n\n<li><strong>CircleCI<\/strong>: Flexible and integrated with multiple cloud providers.<\/li>\n\n\n\n<li><strong>Jenkins<\/strong>: A long-standing, open-source automation server for complex pipelines.<\/li>\n<\/ul>\n\n\n\n<p>For a Sanity and Next.js project, a typical pipeline uses <strong>GitHub Actions<\/strong> to run tests, build the app, and deploy automatically to Vercel, while triggering Sanity\u2019s rebuild hooks when new content is published.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"why-is-ci-cd-important-for-a-sanity-next-js-project\"><span class=\"underline-accent\">Why is CI\/CD Important for a Sanity &amp; Next.js Project?<\/span><\/h3>\n\n\n\n<p>&nbsp;In a Sanity and Next.js setup, <strong>CI\/CD helps you deploy content and code changes<\/strong> efficiently, without rebuilding everything from scratch.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-do-i-set-up-ci-cd-for-sanity-in-a-next-js-project\"><span class=\"underline-accent\">How Do I Set Up CI\/CD for Sanity in a Next.Js Project?<\/span><\/h3>\n\n\n\n<p>You need to connect Sanity to your version control (e.g. GitHub), store required credentials (project ID, dataset, token) as secrets, and set up a workflow that runs Sanity deploy on pushes to specific branches. You can see a more detailed walkthrough in the \u201c<strong>Setting Up Sanity<\/strong>\u201d section above.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"does-this-setup-support-real-time-content-updates-live-previews\"><span class=\"underline-accent\">Does This Setup Support Real-Time Content Updates \/ Live Previews?<\/span><\/h3>\n\n\n\n<p>Yes. Combining Sanity\u2019s live content editing or preview APIs with Next.js preview mode <strong>allows editors to see changes in real time before publishing<\/strong>. The CI\/CD process ensures that published changes are reflected in production builds.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-do-i-manage-environment-variables-securely\"><span class=\"underline-accent\">How Do I Manage Environment Variables Securely?&nbsp;<\/span><\/h3>\n\n\n\n<p>Use encrypted secrets (e.g. GitHub Secrets, Vercel Environment Variables) to store project IDs, datasets, tokens, and API keys. <strong>Never hard-code them in your repository<\/strong>. In CI workflows, reference them via environment variables.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-can-i-speed-up-build-and-deployment-times\"><span class=\"underline-accent\">How Can I Speed Up Build And Deployment Times?<\/span><\/h3>\n\n\n\n<p>Use caching for dependencies, selectively rebuild changed pages (with ISR or incremental builds), and <strong>avoid redeploying unaffected parts<\/strong>. Minimal workflow steps and parallelization help as well.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-much-effort-and-time-does-it-take-to-set-up-ci-cd-for-sanity-with-next-js\"><span class=\"underline-accent\">How Much Effort and Time Does it Take to Set Up CI\/CD for Sanity with Next.js?<\/span><\/h3>\n\n\n\n<p>For a basic setup, <strong>it can take around 1 hour<\/strong> (configuring repos, secrets, a simple action, and deployment) but yields savings of many later development hours. Once set up, most changes deploy automatically with minimal manual overhead.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Explore hosting, CI\/CD, and optimizing your content management system for modern web apps with Sanity and Next.js.<\/p>\n","protected":false},"author":16,"featured_media":19855,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[659,673],"tags":[317,360,316],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Set Up a Sanity and Next.js CI\/CD Pipeline<\/title>\n<meta name=\"description\" content=\"Explore hosting, Sanity Nextjs CI\/CD, and optimizing your content management system for modern web applications.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Set Up a Sanity and Next.js CI\/CD Pipeline\" \/>\n<meta property=\"og:description\" content=\"Explore hosting, Sanity Nextjs CI\/CD, and optimizing your content management system for modern web applications.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/\" \/>\n<meta property=\"og:site_name\" content=\"Pagepro\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/thisispagepro\" \/>\n<meta property=\"article:published_time\" content=\"2025-10-17T08:33:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-06T12:09:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2025\/10\/Sanity-and-Nextjs-for-CI-CD.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"582\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Jakub Dakowicz\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jakub Dakowicz\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"18 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/\"},\"author\":{\"name\":\"Jakub Dakowicz\",\"@id\":\"https:\/\/pagepro.co\/blog\/#\/schema\/person\/66e00cf32ef7d2d1b010523eff380caf\"},\"headline\":\"Sanity and Nextjs for CI \/ CD\",\"datePublished\":\"2025-10-17T08:33:46+00:00\",\"dateModified\":\"2025-11-06T12:09:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/\"},\"wordCount\":2881,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/pagepro.co\/blog\/#organization\"},\"keywords\":[\"for developers\",\"next.js\",\"webdev\"],\"articleSection\":[\"Next js\",\"Sanity\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/\",\"url\":\"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/\",\"name\":\"How to Set Up a Sanity and Next.js CI\/CD Pipeline\",\"isPartOf\":{\"@id\":\"https:\/\/pagepro.co\/blog\/#website\"},\"datePublished\":\"2025-10-17T08:33:46+00:00\",\"dateModified\":\"2025-11-06T12:09:19+00:00\",\"description\":\"Explore hosting, Sanity Nextjs CI\/CD, and optimizing your content management system for modern web applications.\",\"breadcrumb\":{\"@id\":\"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/pagepro.co\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Blog\",\"item\":\"https:\/\/pagepro.co\/blog\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Sanity and Nextjs for CI \/ CD\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/pagepro.co\/blog\/#website\",\"url\":\"https:\/\/pagepro.co\/blog\/\",\"name\":\"Pagepro\",\"description\":\"Frictionless Next.js, Expo &amp; Sanity Development Blog\",\"publisher\":{\"@id\":\"https:\/\/pagepro.co\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/pagepro.co\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/pagepro.co\/blog\/#organization\",\"name\":\"Pagepro\",\"url\":\"https:\/\/pagepro.co\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/pagepro.co\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2020\/08\/logo_pagepro-b66d228a1e-1.png\",\"contentUrl\":\"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2020\/08\/logo_pagepro-b66d228a1e-1.png\",\"width\":440,\"height\":200,\"caption\":\"Pagepro\"},\"image\":{\"@id\":\"https:\/\/pagepro.co\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/thisispagepro\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/pagepro.co\/blog\/#\/schema\/person\/66e00cf32ef7d2d1b010523eff380caf\",\"name\":\"Jakub Dakowicz\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/pagepro.co\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5e0855c6f563f4e1a4a53206089ce0cc?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5e0855c6f563f4e1a4a53206089ce0cc?s=96&d=mm&r=g\",\"caption\":\"Jakub Dakowicz\"},\"description\":\"Jakub is the Chief Technology Officer at Pagepro, where he leads technical strategy and oversees the architecture of complex web platforms built with Next.js and headless CMS solutions. With nearly nine years at Pagepro and over five years leading the engineering team, he has been instrumental in shaping the company\u2019s architectural standards, development workflows, and scalability practices. Jakub focuses on building robust, composable systems that balance performance, maintainability, and long-term business flexibility. He drives technical decision-making across projects, ensuring that solutions are not only modern, but strategically aligned with client growth.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/jakub-dakowicz-939838102\/\"],\"url\":\"https:\/\/pagepro.co\/blog\/author\/jakub_dakowicz\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Set Up a Sanity and Next.js CI\/CD Pipeline","description":"Explore hosting, Sanity Nextjs CI\/CD, and optimizing your content management system for modern web applications.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/","og_locale":"en_US","og_type":"article","og_title":"How to Set Up a Sanity and Next.js CI\/CD Pipeline","og_description":"Explore hosting, Sanity Nextjs CI\/CD, and optimizing your content management system for modern web applications.","og_url":"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/","og_site_name":"Pagepro","article_publisher":"https:\/\/www.facebook.com\/thisispagepro","article_published_time":"2025-10-17T08:33:46+00:00","article_modified_time":"2025-11-06T12:09:19+00:00","og_image":[{"width":1024,"height":582,"url":"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2025\/10\/Sanity-and-Nextjs-for-CI-CD.png","type":"image\/png"}],"author":"Jakub Dakowicz","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Jakub Dakowicz","Est. reading time":"18 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/#article","isPartOf":{"@id":"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/"},"author":{"name":"Jakub Dakowicz","@id":"https:\/\/pagepro.co\/blog\/#\/schema\/person\/66e00cf32ef7d2d1b010523eff380caf"},"headline":"Sanity and Nextjs for CI \/ CD","datePublished":"2025-10-17T08:33:46+00:00","dateModified":"2025-11-06T12:09:19+00:00","mainEntityOfPage":{"@id":"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/"},"wordCount":2881,"commentCount":0,"publisher":{"@id":"https:\/\/pagepro.co\/blog\/#organization"},"keywords":["for developers","next.js","webdev"],"articleSection":["Next js","Sanity"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/","url":"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/","name":"How to Set Up a Sanity and Next.js CI\/CD Pipeline","isPartOf":{"@id":"https:\/\/pagepro.co\/blog\/#website"},"datePublished":"2025-10-17T08:33:46+00:00","dateModified":"2025-11-06T12:09:19+00:00","description":"Explore hosting, Sanity Nextjs CI\/CD, and optimizing your content management system for modern web applications.","breadcrumb":{"@id":"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/pagepro.co\/blog\/sanity-and-nextjs-for-ci-cd\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/pagepro.co\/"},{"@type":"ListItem","position":2,"name":"Blog","item":"https:\/\/pagepro.co\/blog\/"},{"@type":"ListItem","position":3,"name":"Sanity and Nextjs for CI \/ CD"}]},{"@type":"WebSite","@id":"https:\/\/pagepro.co\/blog\/#website","url":"https:\/\/pagepro.co\/blog\/","name":"Pagepro","description":"Frictionless Next.js, Expo &amp; Sanity Development Blog","publisher":{"@id":"https:\/\/pagepro.co\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/pagepro.co\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/pagepro.co\/blog\/#organization","name":"Pagepro","url":"https:\/\/pagepro.co\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/pagepro.co\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2020\/08\/logo_pagepro-b66d228a1e-1.png","contentUrl":"https:\/\/pagepro.co\/blog\/wp-content\/uploads\/2020\/08\/logo_pagepro-b66d228a1e-1.png","width":440,"height":200,"caption":"Pagepro"},"image":{"@id":"https:\/\/pagepro.co\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/thisispagepro"]},{"@type":"Person","@id":"https:\/\/pagepro.co\/blog\/#\/schema\/person\/66e00cf32ef7d2d1b010523eff380caf","name":"Jakub Dakowicz","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/pagepro.co\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/5e0855c6f563f4e1a4a53206089ce0cc?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5e0855c6f563f4e1a4a53206089ce0cc?s=96&d=mm&r=g","caption":"Jakub Dakowicz"},"description":"Jakub is the Chief Technology Officer at Pagepro, where he leads technical strategy and oversees the architecture of complex web platforms built with Next.js and headless CMS solutions. With nearly nine years at Pagepro and over five years leading the engineering team, he has been instrumental in shaping the company\u2019s architectural standards, development workflows, and scalability practices. Jakub focuses on building robust, composable systems that balance performance, maintainability, and long-term business flexibility. He drives technical decision-making across projects, ensuring that solutions are not only modern, but strategically aligned with client growth.","sameAs":["https:\/\/www.linkedin.com\/in\/jakub-dakowicz-939838102\/"],"url":"https:\/\/pagepro.co\/blog\/author\/jakub_dakowicz\/"}]}},"acf":[],"_links":{"self":[{"href":"https:\/\/pagepro.co\/blog\/wp-json\/wp\/v2\/posts\/18309"}],"collection":[{"href":"https:\/\/pagepro.co\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pagepro.co\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pagepro.co\/blog\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/pagepro.co\/blog\/wp-json\/wp\/v2\/comments?post=18309"}],"version-history":[{"count":30,"href":"https:\/\/pagepro.co\/blog\/wp-json\/wp\/v2\/posts\/18309\/revisions"}],"predecessor-version":[{"id":19938,"href":"https:\/\/pagepro.co\/blog\/wp-json\/wp\/v2\/posts\/18309\/revisions\/19938"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pagepro.co\/blog\/wp-json\/wp\/v2\/media\/19855"}],"wp:attachment":[{"href":"https:\/\/pagepro.co\/blog\/wp-json\/wp\/v2\/media?parent=18309"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pagepro.co\/blog\/wp-json\/wp\/v2\/categories?post=18309"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pagepro.co\/blog\/wp-json\/wp\/v2\/tags?post=18309"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}