Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/next/src/client/components/get-params.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { staticGenerationAsyncStorage } from './static-generation-async-storage.external'

export const getParams = () => {
const store = staticGenerationAsyncStorage.getStore()

if (!store) return null

const { params } = store

return params
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import type { PrerenderState } from '../../server/app-render/dynamic-rendering'

// Share the instance module in the next-shared layer
import { staticGenerationAsyncStorage } from './static-generation-async-storage-instance' with { 'turbopack-transition': 'next-shared' }
import type { ParsedUrlQuery } from 'querystring'

export interface StaticGenerationStore {
readonly isStaticGeneration: boolean
readonly pagePath?: string
readonly urlPathname: string
readonly params?: ParsedUrlQuery
readonly incrementalCache?: IncrementalCache
readonly isOnDemandRevalidate?: boolean
readonly isPrerendering?: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { RenderOptsPartial } from '../app-render/types'

import { createPrerenderState } from '../../server/app-render/dynamic-rendering'
import type { FetchMetric } from '../base-http'
import type { ParsedUrlQuery } from 'querystring'

export type StaticGenerationContext = {
urlPathname: string
Expand All @@ -17,6 +18,7 @@ export type StaticGenerationContext = {
isServerAction?: boolean
waitUntil?: Promise<any>
experimental?: Pick<RenderOptsPartial['experimental'], 'isRoutePPREnabled'>
params?: ParsedUrlQuery

/**
* Fetch metrics attached in patch-fetch.ts
Expand Down Expand Up @@ -84,6 +86,7 @@ export const StaticGenerationAsyncStorageWrapper: AsyncStorageWrapper<
const store: StaticGenerationStore = {
isStaticGeneration,
urlPathname,
params: renderOpts.params,
pagePath: renderOpts.originalPathname,
incrementalCache:
// we fallback to a global incremental cache for edge-runtime locally
Expand Down