Skip to content

Commit 26a59eb

Browse files
committed
docs: first pass at 2.0 announcement post
1 parent 386ac0f commit 26a59eb

File tree

1 file changed

+104
-4
lines changed

1 file changed

+104
-4
lines changed
Lines changed: 104 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,110 @@
11
---
22
title: Next-Drupal 2.0
33
author: brianperry
4-
date: October 31, 2024
5-
created: "2024-10-31"
6-
excerpt: Next.js 14, Drupal 11 and App Router Support.
4+
date: January 10, 2025
5+
created: "2025-01-25"
6+
excerpt: Next.js 15, Drupal 11 and App Router Support.
77
published: true
88
---
99

10-
Write this post.
10+
After multiple alpha and beta releases, we're excited to announce the stable release of Next-Drupal 2.0. This release brings long-awaited **App Router support**, along with support for **Next.js 15** and **Drupal 11**.
11+
12+
As part of our App Router support we've also added **tag-based invalidation** which allows you to invalidate content on your Next.js site using Drupal's powerful cache tag system.
13+
14+
---
15+
16+
## App Router
17+
18+
Next-Drupal 2.0 uses the App Router by default to match Next.js, but we will continue to provide support for the Pages Router.
19+
20+
### Starters
21+
22+
The Next-Drupal basic starter is now configured to use the App Router by default.
23+
24+
Run the following command to create a new Next.js project using the App Router:
25+
26+
```sh
27+
npx create-next-app -e https://github.com/chapter-three/next-drupal-basic-starter
28+
```
29+
30+
The Pages router version of the basic starter is also available, now named `next-drupal-pages-starter`.
31+
32+
Run the following command to create a new Next.js project using the Pages Router:
33+
34+
```sh
35+
npx create-next-app -e https://github.com/chapter-three/next-drupal-pages-starter
36+
```
37+
38+
### NextDrupal Client
39+
40+
Similarly, the Next-Drupal Client has been divided into a version compatible with the App Router and a version compatible with the Pages Router.
41+
42+
Create an instance of `NextDrupal` to use the client with the App Router:
43+
44+
```js
45+
import { NextDrupal } from "next-drupal"
46+
47+
// Create a new NextDrupal client.
48+
const drupal = new NextDrupal("https://example.com")
49+
```
50+
51+
Create an instance of `NextDrupalPages` to use the client with the Pages Router:
52+
53+
```js
54+
import { NextDrupalPages } from "next-drupal"
55+
56+
// Create a new NextDrupal client.
57+
const drupal = new NextDrupalPages("https://example.com")
58+
```
59+
60+
Backwards compatibility is also provided for instances of `DrupalClient` which will continue to work with the Pages Router.
61+
62+
### Documentation
63+
64+
Our documentation has been updated to reflect these changes and new features. All examples in our documentation now assume the App Router by default, but call out any Page Router specific differences where applicable.
65+
66+
---
67+
68+
## Tag-based Invalidation
69+
70+
For Next.js entity types configured in Drupal, a new 'tags' plugin can be selected under the on-demand revalidation options. When an entity of that type is updated, Drupal will now make a request to the Next.js revalidation endpoint and provide all associated cache tags. The API endpoint will then use Next's `invalidateTags` method to invalidate data related to the associated tags.
71+
72+
For this to be useful, it is also necessary to set tags within your Next.js site. `NextDrupal` Client methods like `getResource` now accept a `tags` option which expects an array of cache tag values:
73+
74+
```tsx title=app/[...slug]/page.tsx
75+
// app/[...slug]/page.tsx
76+
export default function Page({ params }) {
77+
const {slug} = params;
78+
const path = drupal.translatePath(slug)
79+
80+
// Create a tag in the format of `entity_type:entity_id`.
81+
const tag = `${path.entity.type}:${path.entity.id}`
82+
83+
const node = await drupal.getResource(path, path.entity.uuid {
84+
// Provide the cache tag when requesting the resource.
85+
tags: [tag]
86+
})
87+
88+
return <PageComponent node={node}/>
89+
}
90+
```
91+
92+
This will associate the page data with the provided cache tag.
93+
94+
This configuration can provide much more targeted cache invalidation than path based invalidation alone.
95+
96+
---
97+
98+
## Compatibility
99+
100+
We have updated all of the next-drupal starters (JSON:API and GraphQL) to Next.js 15.
101+
102+
The next module has been updated to Drupal 11. We've removed all deprecated code and APIs.
103+
104+
Following end-of-life for the projects themselves, we no longer officially support Next.js 13 or Drupal 9.
105+
106+
---
107+
108+
## Upgrading
109+
110+
You can upgrade to `2.0` by following our upgrade guide [here](/docs/upgrade-guide).

0 commit comments

Comments
 (0)