microCMS
Documentation
  • Pricing
  • Blog
  • FAQ
  • Contact
  • Sign In
  • Get started for free
Navigation
Tutorial
Next.js
  • Integration with Next.js
  • Getting Started with App Router
  • Tutorial (App Router)
  • Getting Started with Pages Router
  • Tutorial (Pages Router)
Astro
  • Getting Started
  • Integration with Astro
  • Tutorial
Nuxt
  • Integration with Nuxt
  • Getting Started
  • Tutorial
Gatsby
  • Integration with Gatsby
  • Getting Started
  • Tutorial
JavaScript
  • Integration with JavaScript
  • Getting Started (Browser)
  • Getting Started (Server)
PHP
  • Integration with PHP
  • Getting Started
Ruby
  • Integration with Ruby
  • Getting Started
Go
  • Integration with Go
  • Getting Started with microCMS
Manual
  • Introduction
Account & Login
  • Account Registration
  • Login
  • Email Address Authentication
Services
  • Creating a Service
  • Service Configuration
  • Template
  • Service Deletion
Payment
  • Change of Pricing Plan
  • Registering and Changing Payment Methods
API
  • Creating and Managing APIs
  • API Settings
  • Export/Import of API Schema
Fields
  • Text Field
  • Text Area
  • Image
  • Multiple Images
  • Date
  • Boolean
  • Selectable Field
  • Content Reference
  • Multiple Content References
  • Number
  • File
  • Extended Field
  • Repetition
  • Custom
Contents
  • CSV Export of Content
  • Content Creation
  • Content Editing
  • Content Management
  • View
  • Content Status
  • Custom Status
  • Setting the Content ID
  • Automatically Assigned Values for Content
  • CSV Import of Content
  • API Preview
  • Examples of Using Query Parameters with API Preview
  • Integration Methods by Rendering Type
  • Screen Preview
  • Setting Up Webhooks for Content
Rich Editor
  • How to Use the Rich Editor
  • Rich Editor WRITE API
  • How to Use the Old Rich Editor
Reviews
  • Review
  • AI Review
Media
  • Media Management
  • Changing Media Filters and Display Order
  • Media Tag Configuration
  • Setting Up Media Webhooks
  • Custom Domain Settings for Media
Permission Management
  • Member Management
  • Roles (Permission Management in the Admin Panel)
Environments
  • Multiple Environments (Development Environment)
  • Merging API Settings Between Environments
Connection
  • Amazon S3 Integration
Logs
  • Audit Log
  • Data Transfer Volume
Security
  • Content Update History
  • IP Restrictions for Management Dashboard
  • IP Restrictions for APIs
Authentication
  • Setting Up Two-Factor Authentication
  • Mandatory Two-Factor Authentication
  • Single Sign-On
Specifications & Limitations
  • Recommended Environment
  • Limitations / Precautions
Content API
  • What is the Content API?
Basic Operations
  • GET /api/v1/{endpoint}
  • GET /api/v1/{endpoint}/{content_id}
  • POST /api/v1/{endpoint}
  • PUT /api/v1/{endpoint}/{content_id}
  • PATCH /api/v1/{endpoint}/{content_id}
  • DELETE /api/v1/{endpoint}/{content_id}
API Keys
  • API Key (API Authentication and Authorization Management)
  • Migration from the Old API (X-API-KEY, etc.)
Responses & Error Handling
  • Response format for each field in the GET API
  • Specifying Query Parameters in the GET API
  • Error Responses of the Content API
Management API (Beta)
  • POST /api/v1/roles
  • DELETE /api/v1/roles/{role_id}
  • GET /api/v1/roles/{role_id}
  • PATCH /api/v1/roles/{role_id}
  • GET /api/v1/roles
  • What is the Management API?
Content Operations
  • PUT /api/v1/contents/{endpoint}/{content_id}/reservation
  • GET /api/v1/contents/{endpoint}
  • GET /api/v1/contents/{endpoint}/{content_id}
  • PATCH /api/v1/contents/{endpoint}/{content_id}/status
  • PATCH /api/v1/contents/{endpoint}/{content_id}/createdBy
Media Operations
  • GET /api/v2/media
  • GET /api/v1/media
  • POST /api/v1/media
  • DELETE /api/v2/media
Member Operations
  • PATCH /api/v1/members/{member_id}
  • GET /api/v1/members
  • GET /api/v1/members/{member_id}
API Operations
  • POST /api/v1/apis
  • GET /api/v1/apis
  • GET /api/v1/apis/{endpoint}
Service Operations
  • GET /api/v1/service
Responses & Error Handling
  • Management API Error Responses
Image API
  • What is the Image API?
Parameters
  • Image Size
  • Quality
  • Resolution and Screen Size
  • Format
  • Text
  • Border
  • Padding
  • Shape
  • Download
  • Watermark
MCP Server
  • microCMS MCP
  • microCMS Document MCP Server
  • Top
  • Tutorial
  • Next.js

Getting Started with App Router

Last updated: 2026/11/18

This document outlines the steps to use microCMS with Next.js's App Router.
If you are using microCMS from Next.js's App Router for the first time, please try these steps first.

Examples with microCMS Template

There are also examples of templates using Next.js's App Router in the microCMS template.

microCMSテンプレート
https://templates.microcms.io/

You can quickly try out a pre-built environment with just one click, so please refer to this as well.
Search results for "App Router" | microCMS Templates

The following describes how to set up on your own.

Things to Confirm in Advance

  • You will need Node.js and npm to develop with Next.js. Please install them in your development environment.
  • You must have completed the creation of the microCMS service. If you haven't done this, please refer to the documentation below.
Introduction
https://document.microcms.io/en/manual/getting-started

Setting Up microCMS

First, let's create a simple API with microCMS.

  • Object format
  • One text field

In the API creation screen, enter a desired API name and Endpoint.



Next, select the object format.


Finally, set the fields. In this case, we will set only one Text Field.



With the above settings, the API will be created, allowing you to submit content.
Move to the editing screen, enter the desired values, and publish.



At this point, a response containing content data will be returned from the API.
Click on the API Preview in the upper right corner to access the created API and confirm that a JSON response is being returned.


Preparing the Next.js Project

Next, create a Next.js project using the official CLI provided by Next.js. Let's run the following command.

npx create-next-app next-app-microcms

During this process, you will be prompted with the question, “Would you like to use the recommended Next.js defaults?” so select “Yes, use recommended defaults”.



If the operation is successful, the project creation will be complete.
Navigate to the corresponding directory and start the development server.

cd next-app-microcms
npm run dev

Then, access http://localhost:3000 from your browser.
If the server has started successfully, the initial screen will be displayed in the browser as shown below.


Initializing microcms-js-sdk

Next, install the SDK (microcms-js-sdk) for communication with the microCMS API.

$ npm install microcms-js-sdk

Then, create a new libs folder and create a client.js file inside it.

$ mkdir libs
$ touch libs/client.js

Write the following content in the file.

import { createClient } from 'microcms-js-sdk';

export const client = createClient({
  serviceDomain: 'service-domain', 
  apiKey: 'api-key',
});

Here, we will perform the initial configuration of the SDK.
service-domain and api-key will have different values for each service, so appropriate settings are required for the corresponding service.
Set service-domain to the XXXX part of the created service “https://XXXX.microcms.io”. Copy and paste the string of the automatically created API key into api-key. Select “1 API Key” at the bottom of the sidebar, navigate to the API key list, and copy and paste the created API key.

Fetching and Displaying Information from microCMS

Next, fetch information from the microCMS API created earlier and display it on the screen. Let's edit app/page.js.

import styles from './page.module.css'
import { client } from '@/libs/client'

export default async function Home() {
  const data = await client.get({
    endpoint: 'hello',
  })

  return (
    <main className={styles.main}>
      <div className={styles.center}>{data.text}</div>
    </main>
  )
}

Here, we are fetching data from microCMS within the Home component. This component is called a server component, which is processed only on the server side.
This part of the processing will not be included in the final generated JavaScript.

In this case, we are passing the data fetched from microCMS as data to the template for display.
Access http://localhost:3000 at this point.



If it is displayed as shown above, you have successfully connected the data with microCMS.
Try changing the content submitted to microCMS and see if the displayed content changes as well.

Warning

Since the server is running in development mode this time, changes are reflected immediately. However, under the default behavior of server components, changes will not be reflected unless the fetch cache is cleared and a rebuild is performed.
Please refer to the official documentation for more details.

next CLI
https://nextjs.org/docs/pages/api-reference/next-cli
Route Segment Config
https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config
  • Integration with Next.js
  • Tutorial (App Router)

Contents

  • Examples with microCMS Template
  • Things to Confirm in Advance
  • Setting Up microCMS
  • Preparing the Next.js Project
  • Initializing microcms-js-sdk
  • Fetching and Displaying Information from microCMS
  • Company
  • Legal Notice
  • Terms of Service
  • Privacy Policy

Copyright © microcms.io All rights reserved.