Gathering detailed insights and metrics for @gasket/nextjs
Gathering detailed insights and metrics for @gasket/nextjs
Gathering detailed insights and metrics for @gasket/nextjs
Gathering detailed insights and metrics for @gasket/nextjs
npm install @gasket/nextjs
Typescript
Module System
Node Version
NPM Version
@gasket/plugin-git@7.4.3
Updated on Jul 03, 2025
@gasket/plugin-data@7.4.5
Updated on Jul 03, 2025
@gasket/preset-nextjs@7.4.9
Updated on Jul 03, 2025
@gasket/preset-api@7.4.6
Updated on Jul 03, 2025
@gasket/plugin-docs@7.4.4
Updated on Jul 03, 2025
@gasket/react-intl@7.5.4
Updated on Jul 03, 2025
JavaScript (95.29%)
TypeScript (3.24%)
CSS (1.3%)
HTML (0.18%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
138 Stars
1,585 Commits
77 Forks
17 Watchers
36 Branches
78 Contributors
Updated on Jul 10, 2025
Latest Version
7.6.0
Package Id
@gasket/nextjs@7.6.0
Unpacked Size
41.08 kB
Size
10.57 kB
File Count
36
NPM Version
10.9.2
Node Version
22.16.0
Published on
Jul 10, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
23
Gasket integrations for Next.js apps. Provides several tools:
npm i @gasket/nextjs
Get a normalized GasketRequest unique to the current request in server components.
This uses the Next.js cookies()
and headers()
dynamic functions.
Signature
await request(params?: object): GasketRequest
Props
[query]
- (object) Optional query objectMany GasketActions are designed to be unique to requests. When using ServerComponents with Next.js, the incoming request object is not fully accessible. This function provides a way to get a normalized request-like object that can be used with GasketActions from ServerComponents.
1import { request } from '@gasket/nextjs/request'; 2import gasket from '../gasket.mjs' 3 4export default async function MyPage(props) { 5 const req = await request(); 6 const something = await gasket.actions.getSomething(req); 7 8 return <div>{ something.fancy }</div>; 9}
The req
will be a GasketRequest with headers and cookies.
If a query object is passed in, it will be added to the request object as well.
For server components, dynamic routes params are available via props, and can
be passed to the request
function to make those path params available as the
query.
1import { request } from '@gasket/nextjs/request'; 2import gasket from '../gasket.mjs' 3 4export default async function MyDynamicRoutePage({ params }) { 5 const req = request(params); 6 const something = await gasket.actions.getSomething(req); 7 8 return <div>{ something.fancy }</div>; 9}
Use this to extend your Next.js Document to automatically inject a script containing the gasketData
for use with
the @gasket/data package.
Signature
withGasketData(options)(Document)
Props
[options]
- (object) Optional configuration
index
- (number) Force the script to be inject at a certain child index of the bodyThis is the simplest and most common setup:
1// pages/_document.js 2import Document from 'next/document'; 3import { withGasketData } from '@gasket/nextjs/document'; 4import gasket from '../gasket.js'; 5 6export default withGasketData(gasket)(Document);
By default this will inject the script in the <body/>
after the Next.js
<Main/>
component, but before <NextScript/>
. This also works for a
custom Document.
However, there may be situations where you want to inject the gasketData
script at a particular child index of the <body/>
. To do so, you can set the
index
in the decorator options.
1// pages/_document.js 2import Document, {Html, Head, Main, NextScript} from 'next/document' 3import { withGasketData } from '@gasket/nextjs/document'; 4import gasket from '../gasket.js'; 5 6class MyDocument extends Document { 7 static async getInitialProps(ctx) { 8 const initialProps = await Document.getInitialProps(ctx) 9 return {...initialProps} 10 } 11 12 render() { 13 return ( 14 <Html> 15 <Head/> 16 <body> 17 <Main/> 18 <footer>Some custom content</footer> 19 <NextScript/> 20 </body> 21 </Html> 22 ) 23 } 24} 25 26export default withGasketData(gasket, {index: 2})(MyDocument);
In this example, the gasketData
script will be injected after the custom
<footer/>
instead of right after <Main/>
.
This is especially useful if you are somehow nesting or extending the <Main/>
and <NextScript/>
components and the decorator cannot find the right place to inject the script.
Use this to allow gasket data to be accessed with the useGasketData
hook. This is SSR
and client side friendly and can be added at the app level or component level.
1// pages/_app.js 2import { AppProps } from 'next/app'; 3import { withGasketDataProvider } from '@gasket/nextjs'; 4import gasket from '../gasket.js'; 5 6 7const Root = ({ Page, pageProps }) => { 8 return ( 9 <Page {...pageProps} /> 10 ); 11}; 12 13export default withGasketDataProvider(gasket)(Root);
Use this hook to access the gasketData provided by the withGasketDataProvider
hoc.
1// MyComponent.js 2import { useGasketData } from '@gasket/nextjs'; 3 4 5export const MyComponent = (props) => { 6 const gasketData = useGasketData(); 7 8 return ( 9 <> 10 <div>{gasketData.something}</div> 11 <div>{gasketData.here}</div> 12 </> 13 ); 14};
During server side rendering, lifecycles' data can be added to the gasketData property. When the withGasketData
hoc is added to a custom Next.js _document, the gasketData is added to the rendered html inside a script tag.
The withGasketDataProvider
can be added to a Next.js custom _app or react component. This HOC will capture the gasket data from server side gasketData property or the script tag that was rendered to the html. If Next.js is preforming a SSR the data will come from the gasketData property, otherwise the data will come from the script tag. The withGasketDataProvider
hoc will then create a provider and inject gasket data into a context that can be consumed by the useGasketData
hook.
The useGasketData
will provide access to the gasket data within the context of the withGasketDataProvider
, allowing data to be used within any react component.
Please see @gasket/data docs for examples on adding data during SSR lifecycle
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
security policy file detected
Details
Reason
Found 17/19 approved changesets -- score normalized to 8
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
21 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More