You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+115-8Lines changed: 115 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,7 @@ Give me a ⭐ if you like it.
15
15
- Support SSR (Server-Side Rendering), SSG (Static Site Generation) and CSR (Client-Side Rendering)
16
16
- Support TypeScript
17
17
- Zero Dependencies
18
+
- Dummy Ad Support for Development - Preview ads locally without real AdSense integration
18
19
- Theoretically support all AdSense AD types (see [🎨 Create a custom layout](#-create-a-custom-layout) for more details)
19
20
- Create `ads.txt` automatically (see [Initialization / Verification](#initialization--verification-) for more details)
20
21
@@ -28,10 +29,14 @@ Give me a ⭐ if you like it.
28
29
-[Usage](#usage-)
29
30
-[Auto Ads](#auto-ads)
30
31
-[Manual Ads](#manual-ads)
32
+
-[Dummy Ads for Development](#dummy-ads-for-development-)
31
33
-[📖 API Reference](#-api-reference)
32
34
-[Components](#components)
33
35
-[GoogleAdSense](#initializes-the-google-adsense)
34
36
-[AdUnit](#manual-ad)
37
+
-[Ad Sizes](#ad-sizes)
38
+
-[Display Ad Sizes](#display-ad-sizes)
39
+
-[In-Article Ad Sizes](#in-article-ad-sizes)
35
40
-[🎨 Create a custom layout](#-create-a-custom-layout)
36
41
-[How to convert the given html to a custom layout?](#how-to-convert-the-given-html-to-a-custom-layout)
37
42
-[🐛 Known Issues](#-known-issues)
@@ -52,6 +57,7 @@ Give me a ⭐ if you like it.
52
57
| Support Matched Content Ad | ✅ | ❌ |
53
58
| Dynamic `ads.txt`| ✅ | ❌ |
54
59
| Multiple ADs on one page | ✅ | ⚠️\*1 |
60
+
| Dummy Ad for Development | ✅ | ❌ |
55
61
56
62
\*1: According to the their [documentation](https://github.com/btk/nextjs-google-adsense/blob/master/README.md) seems it is ok to use multiple ADs on one page. But I found that it will cause an error.
57
63
@@ -125,6 +131,9 @@ If you decide to use Auto Ads, you are good to go. The ads will be automatically
125
131
126
132
#### Manual Ads
127
133
134
+
> [!NOTE]\
135
+
> Google AdSense does't work in local environment. You need to test it in production or use [Dummy Ads for Development](#dummy-ads-for-development-).
136
+
128
137
```typescript
129
138
import { AdUnit } from"next-google-adsense";
130
139
@@ -150,6 +159,54 @@ const Page = () => {
150
159
exportdefaultPage;
151
160
```
152
161
162
+
#### Dummy Ads for Development 🧪
163
+
164
+
Perfect for development and testing! Show realistic ad placeholders without needing actual AdSense approval.
> Dummy ads only appear when the `dummySize` prop is provided. In production (when `NODE_ENV`/`NEXT_PUBLIC_ENV` is not "development"), real ads will be displayed instead.
| publisherId | Yes | string | n/a | You can skip this parameter if you set the environment variable `NEXT_PUBLIC_ADSENSE_PUBLISHER_ID`. |
233
+
| slotId | No | string | n/a | Google AdSense Slot ID. |
234
+
| layout | Yes | "display" \| "in-article" \| "custom" | "display" | The layout of the AD. |
235
+
| customLayout | Yes | JSX.Element | n/a | The custom layout of the AD. This parameter is required if `layout` is set to "custom". |
236
+
| dummySize | Yes | DisplayAdSize \| ArticleAdSize \| {width: number, height: number} | n/a | Show dummy ad for development. Only appears when this prop is provided. |
0 commit comments