Skip to content

Commit e538a2f

Browse files
authored
Merge pull request #12 from aidenybai/feat/installation-docs
Add Framework Specific Installation
2 parents 60a0019 + a367444 commit e538a2f

File tree

6 files changed

+4419
-2737
lines changed

6 files changed

+4419
-2737
lines changed

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,72 @@ const ExpensiveComponent = withScan(
5757

5858
And voilà! You're ready to go.
5959

60+
## Framework-specific Installation
61+
62+
### Next.js (Pages Router)
63+
64+
Add the script tag to your `pages/_document.tsx`:
65+
66+
```jsx
67+
import { Html, Head, Main, NextScript } from 'next/document'
68+
69+
export default function Document() {
70+
return (
71+
<Html lang="en">
72+
<Head>
73+
+ <script src="https://unpkg.com/react-scan/dist/auto.global.js"></script>
74+
75+
{/* rest of your scripts go under */}
76+
</Head>
77+
<body>
78+
<Main />
79+
<NextScript />
80+
</body>
81+
</Html>
82+
)
83+
}
84+
```
85+
86+
### Next.js (App Router)
87+
88+
Add the script tag to your `app/layout.tsx`:
89+
90+
```jsx
91+
export default function RootLayout({
92+
children,
93+
}: {
94+
children: React.ReactNode
95+
}) {
96+
return (
97+
<html lang="en">
98+
<head>
99+
<script src="https://unpkg.com/react-scan/dist/auto.global.js"></script>
100+
{/* rest of your scripts go under */}
101+
</head>
102+
<body>{children}</body>
103+
</html>
104+
)
105+
}
106+
```
107+
108+
### Vite / Create React App / Remix
109+
110+
Add the script tag to your `index.html`:
111+
112+
```html
113+
<!DOCTYPE html>
114+
<html lang="en">
115+
<head>
116+
<script src="https://unpkg.com/react-scan/dist/auto.global.js"></script>
117+
118+
<!-- rest of your scripts go under -->
119+
</head>
120+
<body>
121+
<!-- ... -->
122+
</body>
123+
</html>
124+
```
125+
60126
## Why React Scan?
61127

62128
React can be tricky to optimize.

0 commit comments

Comments
 (0)