Skip to content

Commit 3ebd677

Browse files
committed
Add nextjs app router example
1 parent a9aa6dc commit 3ebd677

File tree

19 files changed

+272
-3
lines changed

19 files changed

+272
-3
lines changed
File renamed without changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# react-use-intercom in NextJS (App Router)
2+
3+
Replace `INTERCOM_APP_ID` with your Intercom app id.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use client';
2+
3+
import { IntercomProvider } from 'react-use-intercom';
4+
5+
const INTERCOM_APP_ID = 'jcabc7e3';
6+
7+
export function OurIntercomProvider({ children }) {
8+
return (
9+
<html lang="en">
10+
<body>
11+
<IntercomProvider appId={INTERCOM_APP_ID}>
12+
{children}
13+
</IntercomProvider>
14+
</body>
15+
</html>
16+
);
17+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { OurIntercomProvider } from './intercom';
2+
3+
export default function RootLayout({ children }) {
4+
return (
5+
<html lang="en">
6+
<body>
7+
<OurIntercomProvider>
8+
{children}
9+
</OurIntercomProvider>
10+
</body>
11+
</html>
12+
);
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use client';
2+
3+
import { useIntercom } from "react-use-intercom";
4+
5+
export default function Home() {
6+
const { boot } = useIntercom();
7+
8+
return (
9+
<main>
10+
<button onClick={() => boot()}>Boot</button>
11+
</main>
12+
);
13+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "nextjs-app-router-example",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev --port 3001",
7+
"build": "next build",
8+
"start": "next start"
9+
},
10+
"dependencies": {
11+
"next": "^14.0.0",
12+
"react": "^18.2.0",
13+
"react-dom": "^18.2.0",
14+
"react-use-intercom": "workspace:*"
15+
}
16+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"container": {
3+
"port": 3001,
4+
"startScript": "dev"
5+
}
6+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env.local
29+
.env.development.local
30+
.env.test.local
31+
.env.production.local
32+
33+
# vercel
34+
.vercel
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# react-use-intercom in NextJS
1+
# react-use-intercom in NextJS (Page Router)
22

33
Replace `INTERCOM_APP_ID` with your Intercom app id.

apps/examples/nextjs/package.json renamed to apps/examples/nextjs-page-router/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"private": true,
3-
"name": "nextjs-example",
3+
"name": "nextjs-page-router-example",
44
"scripts": {
55
"dev": "next dev",
66
"build": "next build",

0 commit comments

Comments
 (0)