# gatsby-source-newt

> Gatsby source plugin for building websites using Newt as a data source

Latest version **2.0.36** (published 2026-07-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install gatsby-source-newt
pnpm add gatsby-source-newt
yarn add gatsby-source-newt
bun add gatsby-source-newt
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 2.0.36 |
| Published | 2026-07-22 |
| First published | 2022-02-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 11.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Newt, Inc. |
| Maintainers | y-meguro, atsushifujikawa |

## Links

- npm: https://www.npmjs.com/package/gatsby-source-newt
- Repository: https://github.com/Newt-Inc/gatsby-source-newt
- Issues: https://github.com/Newt-Inc/gatsby-source-newt/issues
- npm.io page: https://npm.io/package/gatsby-source-newt

## Dependencies (2)

- [camelcase](https://npm.io/package/camelcase.md) ^6.3.0
- [newt-client-js](https://npm.io/package/newt-client-js.md) ^3.3.7

## Recent versions

- 2.0.36 (latest) — 2026-07-22
- 2.0.35 — 2026-06-26
- 2.0.34 — 2026-05-22
- 2.0.33 — 2026-03-17
- 2.0.32 — 2026-02-12
- 2.0.31 — 2025-11-18
- 2.0.30 — 2025-10-21
- 2.0.29 — 2025-09-17
- 2.0.28 — 2025-08-18
- 2.0.27 — 2025-05-21
- 2.0.26 — 2025-04-15
- 2.0.25 — 2024-12-17
- 2.0.24 — 2024-11-19
- 2.0.23 — 2024-10-15
- 2.0.22 — 2024-09-02
- … 24 more at https://npm.io/package/gatsby-source-newt/versions

## README

# End of Life Notice

**The Newt headless CMS will be retired on 2026-11-24.**

2026年11月24日（火）をもちまして、Newt株式会社が提供しているヘッドレスCMS「Newt」のサービス提供を終了させていただくこととなりました。

サービス終了後は、管理画面・APIともにご利用いただくことができなくなります。

これまでヘッドレスCMS「Newt」をご支援・ご愛顧いただき、誠にありがとうございました。

# gatsby-source-newt

## Install

Install the package with:

```sh
npm install gatsby-source-newt

# or

yarn add gatsby-source-newt
```

## Basic Usage

### gatsby-config.js

You need to declare the plugin use and its options in `gatsby-config.js`

```js
module.exports = {
  plugins: [
    {
      resolve: 'gatsby-source-newt',
      options: {
        spaceUid: 'YOUR_SPACE_UID',
        token: 'YOUR_API_TOKEN',
        appUid: 'YOUR_APP_UID',
        models: [{
          uid: 'YOUR_MODEL_UID_1',
        }],
      },
    },
  ],
};

// If you want to source from multiple spaces or multiple apps, add another configuration.
module.exports = {
  plugins: [
    {
      resolve: 'gatsby-source-newt',
      options: {
        spaceUid: 'YOUR_SPACE_UID_1',
        token: 'YOUR_CDN_API_TOKEN_1',
        appUid: 'YOUR_APP_UID_1',
        models: [{
          uid: 'YOUR_MODEL_UID_1',
        }],
      },
    },
    {
      resolve: 'gatsby-source-newt',
      options: {
        spaceUid: 'YOUR_SPACE_UID_2',
        token: 'YOUR_CDN_API_TOKEN_2',
        appUid: 'YOUR_APP_UID_2',
        models: [{
          uid: 'YOUR_MODEL_UID_2',
        }],
      },
    },
  ],
};
```

#### Options

```js
{
  /**
   * `spaceUid` is your space uid.
   *
   * Required
   * Type: String
   **/
  spaceUid: 'YOUR_SPACE_UID',

  /**
   * `token` is an authentication token used for the API.
   * If you use the CDN API, enter the CDN API token; if you use the Newt API, enter the Newt API token.
   *
   * Required
   * Type: String
   **/
  token: 'YOUR_API_TOKEN',

  /**
   * `appUid` is your app uid.
   *
   * Required
   * Type: String
   **/
  appUid: 'blog',

  /**
   * `models` is an array of information about the models you want to source.
   *
   * Required.
   * Type: Array
   **/
  models: [{
    /**
     * `uid` is your model uid.
     *
     * Required
     * Type: String
     **/
    uid: 'article',

    /**
     * `type` is used to name the type in GraphQL.
     * If you specify 'post' as a type, then the type of GraphQL will be 'newtPost' and 'allNewtPost'.
     *
     * Optional
     * Type: String
     * Default: uid value
     **/
    type: 'post',

    /**
     * `query` specifies the condition of the content to be fetched.
     * See below for details on available queries.
     * https://github.com/Newt-Inc/newt-client-js#query-fields
     *
     * Optional
     * Type: Object
     **/
    query: {
      or: [
        { title: { match: 'update' } },
        { title: { match: 'アップデート' } }
      ],
      body: { fmt: 'text' },
    },
  }],

  /**
   * `apiType` specifies the API to be used.
   * If you use the CDN API, enter `cdn`; if you use the Newt API, enter `api`.
   *
   * Optional
   * Type: String
   * Default: `cdn`
   **/
  apiType: 'cdn',
}
```

### gatsby-node.js

```js
const path = require('path')

exports.createPages = async ({graphql, actions}) => {
  const {createPage} = actions

  const result = await graphql(`
    {
      allNewtArticle {
        edges {
          node {
            _id
            slug
          }
        }
      }
    }
  `)

  if (result.errors) {
    throw result.errors
  }

  result.data.allNewtArticle.edges.forEach((edge) => {
    createPage({
      path: edge.node.slug,
      component: path.resolve('./src/templates/article.js'),
      context: {
        _id: edge.node._id
      },
    })
  })
}
```

## License

This repository is published under the [MIT License](https://github.com/Newt-Inc/gatsby-source-newt/blob/main/LICENSE).

---
_Source: https://npm.io/package/gatsby-source-newt · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
