34 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			TypeScript
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			TypeScript
		
	
	
		
			Executable File
		
	
	
	
	
import { type ReadonlyHeaders } from '../web/spec-extension/adapters/headers';
 | 
						|
/**
 | 
						|
 * In this version of Next.js `headers()` returns a Promise however you can still reference the properties of the underlying Headers instance
 | 
						|
 * synchronously to facilitate migration. The `UnsafeUnwrappedHeaders` type is added to your code by a codemod that attempts to automatically
 | 
						|
 * updates callsites to reflect the new Promise return type. There are some cases where `headers()` cannot be automatically converted, namely
 | 
						|
 * when it is used inside a synchronous function and we can't be sure the function can be made async automatically. In these cases we add an
 | 
						|
 * explicit type case to `UnsafeUnwrappedHeaders` to enable typescript to allow for the synchronous usage only where it is actually necessary.
 | 
						|
 *
 | 
						|
 * You should should update these callsites to either be async functions where the `headers()` value can be awaited or you should call `headers()`
 | 
						|
 * from outside and await the return value before passing it into this function.
 | 
						|
 *
 | 
						|
 * You can find instances that require manual migration by searching for `UnsafeUnwrappedHeaders` in your codebase or by search for a comment that
 | 
						|
 * starts with `@next-codemod-error`.
 | 
						|
 *
 | 
						|
 * In a future version of Next.js `headers()` will only return a Promise and you will not be able to access the underlying Headers instance
 | 
						|
 * without awaiting the return value first. When this change happens the type `UnsafeUnwrappedHeaders` will be updated to reflect that is it no longer
 | 
						|
 * usable.
 | 
						|
 *
 | 
						|
 * This type is marked deprecated to help identify it as target for refactoring away.
 | 
						|
 *
 | 
						|
 * @deprecated
 | 
						|
 */
 | 
						|
export type UnsafeUnwrappedHeaders = ReadonlyHeaders;
 | 
						|
/**
 | 
						|
 * This function allows you to read the HTTP incoming request headers in
 | 
						|
 * [Server Components](https://nextjs.org/docs/app/building-your-application/rendering/server-components),
 | 
						|
 * [Server Actions](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations),
 | 
						|
 * [Route Handlers](https://nextjs.org/docs/app/building-your-application/routing/route-handlers) and
 | 
						|
 * [Middleware](https://nextjs.org/docs/app/building-your-application/routing/middleware).
 | 
						|
 *
 | 
						|
 * Read more: [Next.js Docs: `headers`](https://nextjs.org/docs/app/api-reference/functions/headers)
 | 
						|
 */
 | 
						|
export declare function headers(): Promise<ReadonlyHeaders>;
 |