@scalar/nextjs-api-reference 0.8.5 → 0.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +6 -96
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -5,104 +5,14 @@
|
|
|
5
5
|
[](https://www.npmjs.com/package/@scalar/nextjs-api-reference)
|
|
6
6
|
[](https://discord.gg/scalar)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
## Documentation
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/scalar/scalar/assets/2039539/5837adad-a605-4edb-90ec-b929ff2b803b">
|
|
12
|
-
<source media="(prefers-color-scheme: light)" srcset="https://github.com/scalar/scalar/assets/2039539/4f58202d-f40f-47b3-aeaa-44681b424a45">
|
|
13
|
-
<img alt="Screenshot of an API Reference" src="https://github.com/scalar/scalar/assets/2039539/4f58202d-f40f-47b3-aeaa-44681b424a45">
|
|
14
|
-
</picture>
|
|
10
|
+
[Read the documentation here](https://guides.scalar.com/scalar/scalar-api-references/integrations/nextjs)
|
|
15
11
|
|
|
16
|
-
##
|
|
12
|
+
## Community
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
npm install @scalar/nextjs-api-reference
|
|
20
|
-
```
|
|
14
|
+
We are API nerds. You too? Let’s chat on Discord: <https://discord.gg/scalar>
|
|
21
15
|
|
|
22
|
-
##
|
|
16
|
+
## License
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
please use version `0.4.106` of this package.
|
|
26
|
-
|
|
27
|
-
## Usage
|
|
28
|
-
|
|
29
|
-
If you have a OpenAPI/Swagger file already, you can pass a URL to the plugin in an API [Route](https://nextjs.org/docs/app/building-your-application/routing/route-handlers):
|
|
30
|
-
|
|
31
|
-
```ts
|
|
32
|
-
// app/reference/route.ts
|
|
33
|
-
import { ApiReference } from '@scalar/nextjs-api-reference'
|
|
34
|
-
|
|
35
|
-
const config = {
|
|
36
|
-
url: '/openapi.json',
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const GET = ApiReference(config)
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
Or, if you just have a static OpenAPI spec, you can directly pass it as well:
|
|
43
|
-
|
|
44
|
-
```ts
|
|
45
|
-
const config = {
|
|
46
|
-
content: '{ "openapi": "3.1.1", … }',
|
|
47
|
-
}
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
We wrote a [detailed integration guide for Next.js](/documentation/integrations/nextjs.md).
|
|
51
|
-
|
|
52
|
-
The Next.js handler takes our universal configuration object, [read more about configuration](https://github.com/scalar/scalar/tree/main/documentation/configuration.md) in the core package README.
|
|
53
|
-
|
|
54
|
-
## Themes
|
|
55
|
-
|
|
56
|
-
By default, we’re using a custom Next.js theme and it’s beautiful. But you can choose [one of our other themes](https://github.com/scalar/scalar/tree/main/packages/themes), too:
|
|
57
|
-
|
|
58
|
-
```ts
|
|
59
|
-
const config = {
|
|
60
|
-
theme: 'purple',
|
|
61
|
-
}
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Pages router
|
|
65
|
-
|
|
66
|
-
If you are using the pages router, you can import the React component
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
npm install @scalar/api-reference-react
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
```tsx
|
|
73
|
-
'use client'
|
|
74
|
-
|
|
75
|
-
import { ApiReferenceReact } from '@scalar/api-reference-react'
|
|
76
|
-
|
|
77
|
-
import '@scalar/api-reference-react/style.css'
|
|
78
|
-
|
|
79
|
-
export default function References() {
|
|
80
|
-
return (
|
|
81
|
-
<ApiReferenceReact
|
|
82
|
-
configuration={{
|
|
83
|
-
url: 'https://cdn.jsdelivr.net/npm/@scalar/galaxy/dist/latest.json',
|
|
84
|
-
}}
|
|
85
|
-
/>
|
|
86
|
-
)
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Specific CDN version
|
|
91
|
-
|
|
92
|
-
By default, this integration will use the latest version of the `@scalar/api-reference`.
|
|
93
|
-
|
|
94
|
-
You can also pin the CDN to a specific version by specifying it in the CDN string like `https://cdn.jsdelivr.net/npm/@scalar/api-reference@1.25.28`
|
|
95
|
-
|
|
96
|
-
You can find all available CDN versions [here](https://www.jsdelivr.com/package/npm/@scalar/api-reference?tab=files)
|
|
97
|
-
|
|
98
|
-
```ts
|
|
99
|
-
// app/reference/route.ts
|
|
100
|
-
import { ApiReference } from '@scalar/nextjs-api-reference'
|
|
101
|
-
|
|
102
|
-
const config = {
|
|
103
|
-
url: '/openapi.json',
|
|
104
|
-
cdn: 'https://cdn.jsdelivr.net/npm/@scalar/api-reference@latest',
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export const GET = ApiReference(config)
|
|
108
|
-
```
|
|
18
|
+
The source code in this repository is licensed under [MIT](https://github.com/scalar/scalar/blob/main/LICENSE).
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"openapi",
|
|
19
19
|
"swagger"
|
|
20
20
|
],
|
|
21
|
-
"version": "0.8.
|
|
21
|
+
"version": "0.8.7",
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=20"
|
|
24
24
|
},
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
],
|
|
36
36
|
"module": "./dist/index.js",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@scalar/core": "0.3.
|
|
38
|
+
"@scalar/core": "0.3.4"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^20.17.10",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"react-dom": "^19.0.0",
|
|
48
48
|
"vite": "5.4.19",
|
|
49
49
|
"vite-plugin-dts": "^4.3.0",
|
|
50
|
-
"@scalar/api-reference": "1.31.
|
|
50
|
+
"@scalar/api-reference": "1.31.18"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"next": "^15.2.4",
|