Skip to content

Commit bc49314

Browse files
authored
Merge pull request #796 from devrnt/nextjs-app-router-examples
Nextjs app router examples
2 parents a9aa6dc + e83efea commit bc49314

File tree

25 files changed

+283
-26
lines changed

25 files changed

+283
-26
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ Steps to reproduce the behavior:
1717
3. Scroll down to '....'
1818
4. See error
1919

20-
**Codesandbox link**
21-
Include a codesandox will help us to investigate the issue quicker.
20+
**StackBlitz link**
21+
Include a StackBLitz will help us to investigate the issue quicker.
22+
23+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz_small.svg)](https://stackblitz.com/fork/github/devrnt/react-use-intercom/)
2224

2325
**Expected behavior**
2426
A clear and concise description of what you expected to happen.

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
auto-install-peers = true
22
node-linker=hoisted
3+
# This allows us to use workspace packages if available, otherwise pull from the remote registry
4+
link-workspace-packages = true

apps/examples/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Examples
2+
3+
* [gatsby](https://stackblitz.com/github/devrnt/react-use-intercom/tree/main/apps/examples/gatsby)
4+
* [nextjs-page-router](https://stackblitz.com/github/devrnt/react-use-intercom/tree/main/apps/examples/nextjs-page-router)
5+
* [nextjs-app-router](https://stackblitz.com/github/devrnt/react-use-intercom/tree/main/apps/examples/nextjs-app-router)

apps/examples/gatsby/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
"gatsby": "^5.5.0",
1717
"react": "^18.2.0",
1818
"react-dom": "^18.2.0",
19-
"react-use-intercom": "workspace:*"
19+
"react-use-intercom": "*"
2020
}
2121
}

apps/examples/gatsby/sandbox.config.json

Lines changed: 0 additions & 5 deletions
This file was deleted.
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+
}

0 commit comments

Comments
 (0)