Nâng cấp next từ 14.x lên 15.x
So sánh API công khai của next 14.2.35 và 15.5.27, được tính tự động từ kiểu TypeScript. Chữ ký thay đổi là thay đổi có thể không tương thích, không phải điều chắc chắn.
Tóm tắt
| Đường dẫn import bị xóa | 0 |
|---|---|
| Export bị xóa | 4 |
| Chữ ký thay đổi | 10 |
| Thành viên lớp hoặc interface bị xóa | 6 |
| Thành viên lớp hoặc interface thay đổi | 10 |
| Mới bị ngừng hỗ trợ | 5 |
| Thay đổi yêu cầu (engines, phụ thuộc peer) | 5 |
| Export mới | 25 |
Export bị xóa
| import | export | kind | Trước |
|---|---|---|---|
next/constants | GOOGLE_FONT_PROVIDER | variable | "https://fonts.googleapis.com/" |
next/constants | DEV_MIDDLEWARE_MANIFEST | variable | "_devMiddlewareManifest.json" |
next/constants | OPTIMIZED_FONT_PROVIDERS | variable | { url: string; preconnect: string; }[] |
next/constants | AUTOMATIC_FONT_OPTIMIZATION_MANIFEST | variable | "font-manifest.json" |
Chữ ký thay đổi
| export | Trước | Sau |
|---|---|---|
next · default | (options: NextServerOptions): NextServer | (options: Omit<Options | Options, "conf"> & Partial<Pick<Options | Options, "conf">> & { turbo?: boolean | undefined; turbopack?: boolean | undefined; }): NextWrapperServer |
next · PageConfig | { amp?: boolean | "hybrid" | undefined; api?: { responseLimit?: ResponseLimit | undefined; bodyParser?: false | { sizeLimit?: SizeLimit | undefined; } | undefined; externalResolver?: true | undefined; } | undefined; env?: string[] | undefined; maxDuration?: number | undefined; runtime?: ServerRuntime; unstable_runtimeJS?: false | undefined; unstable_JsPreload?: false | undefined; unstable_includeFiles?: string[] | undefined; unstable_excludeFiles?: string[] | undefined; } | { amp?: boolean | "hybrid" | undefined; api?: { responseLimit?: ResponseLimit | undefined; bodyParser?: false | { sizeLimit?: SizeLimit | undefined; } | undefined; externalResolver?: true | undefined; } | undefined; env?: string[] | undefined; maxDuration?: number | undefined; runtime?: ServerRuntime; unstable_runtimeJS?: false | undefined; unstable_JsPreload?: false | undefined; } |
next · GetStaticPathsResult | { paths: (string | { params: Params; locale?: string | undefined; })[]; fallback: boolean | "blocking"; } | { paths: (string | { params: Params; locale?: string | undefined; })[]; fallback: GetStaticPathsFallback; } |
next/link · LinkProps | { href: any; as?: any; replace?: boolean | undefined; scroll?: boolean | undefined; shallow?: boolean | undefined; passHref?: boolean | undefined; prefetch?: boolean | null | undefined; locale?: string | false | undefined; legacyBehavior?: boolean | undefined; onMouseEnter?: any; onTouchStart?: any; onClick?: any; } | interface |
next/error · ErrorProps | { statusCode: number; title?: string | undefined; withDarkMode?: boolean | undefined; } | { statusCode: number; hostname?: string | undefined; title?: string | undefined; withDarkMode?: boolean | undefined; } |
next/dynamic · DynamicOptions | LoadableGeneratedOptions & { loading?: ((loadingProps: DynamicOptionsLoadingProps) => any) | undefined; loader?: LoaderMap | Loader<P> | undefined; loadableGenerated?: LoadableGeneratedOptions | undefined; ssr?: boolean | undefined; suspense?: boolean | undefined; } | LoadableGeneratedOptions & { loading?: ((loadingProps: DynamicOptionsLoadingProps) => React.ReactNode) | undefined; loader?: LoaderMap | Loader<P> | undefined; loadableGenerated?: LoadableGeneratedOptions | undefined; ssr?: boolean | undefined; } |
next/dynamic · LoadableOptions | LoadableGeneratedOptions & { loading?: ((loadingProps: DynamicOptionsLoadingProps) => any) | undefined; loader?: LoaderMap | Loader<P> | undefined; loadableGenerated?: LoadableGeneratedOptions | undefined; ssr?: boolean | undefined; suspense?: boolean | undefined; } | LoadableGeneratedOptions & { loading?: ((loadingProps: DynamicOptionsLoadingProps) => React.ReactNode) | undefined; loader?: LoaderMap | Loader<P> | undefined; loadableGenerated?: LoadableGeneratedOptions | undefined; ssr?: boolean | undefined; } |
next/headers · cookies | (): ReadonlyRequestCookies | (): Promise<ReadonlyRequestCookies> |
next/headers · headers | (): ReadonlyHeaders | (): Promise<ReadonlyHeaders> |
next/headers · draftMode | (): DraftMode | (): Promise<DraftMode> |
Thành viên lớp hoặc interface bị xóa
| member | import | Trước |
|---|---|---|
NextConfig.swcMinify | next | boolean | undefined |
NextConfig.analyticsId | next | string | undefined |
NextConfig.optimizeFonts | next | boolean | undefined |
NextConfig.outputFileTracing | next | boolean | undefined |
Router._getFlightData | next/router | (dataHref: string): Promise<{ data: string; }> |
Head.makeStylesheetInert | next/document | (node: ReactNode[]): ReactNode[] |
Thành viên lớp hoặc interface thay đổi
| member | Trước | Sau |
|---|---|---|
NextConfig.logging | { fetches?: { fullUrl?: boolean | undefined; } | undefined; } | undefined | false | LoggingConfig | undefined |
NextConfig.rewrites | (() => Promise<Rewrite[] | { beforeFiles: Rewrite[]; afterFiles: Rewrite[]; fallback: Rewrite[]; }>) | undefined | (() => Promise<Rewrite[] | { beforeFiles?: Rewrite[] | undefined; afterFiles?: Rewrite[] | undefined; fallback?: Rewrite[] | undefined; }>) | undefined |
NextConfig.sassOptions | { [key: string]: any; } | undefined | { [key: string]: any; implementation?: string | undefined; } | undefined |
NextConfig.devIndicators | { buildActivity?: boolean | undefined; buildActivityPosition?: "bottom-right" | "bottom-left" | "top-right" | "top-left" | undefined; } | undefined | false | { appIsrStatus?: boolean | undefined; buildActivity?: boolean | undefined; buildActivityPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right" | undefined; position?: "top-left" | "top-right" | "bottom-left" | "bottom-right" | undefined; } | undefined |
NextApiRequest.previewData | any | PreviewData |
NextPageContext.locales | string[] | undefined | readonly string[] | undefined |
default.static getInitialProps | ({ res, err, }: NextPageContext): ErrorProps | Promise<ErrorProps> | ({ req, res, err, }: NextPageContext): ErrorProps | Promise<ErrorProps> |
default.static origGetInitialProps | ({ res, err, }: NextPageContext): ErrorProps | Promise<ErrorProps> | ({ req, res, err, }: NextPageContext): ErrorProps | Promise<ErrorProps> |
Router.locales | string[] | undefined | readonly string[] | undefined |
Router.domainLocales | DomainLocale[] | undefined | readonly DomainLocale[] | undefined |
Mới bị ngừng hỗ trợ
| export | @deprecated |
|---|---|
next · NextConfig.amp | built-in amp support will be removed in Next 16 |
next · NextConfig.publicRuntimeConfig | Runtime config is deprecated and will be removed in Next.js 16. |
next · NextConfig.serverRuntimeConfig | Runtime config is deprecated and will be removed in Next.js 16. |
next/config · default | Runtime config is deprecated and will be removed in Next.js 16. |
next/config · setConfig | Runtime config is deprecated and will be removed in Next.js 16. |
Thay đổi yêu cầu (engines, phụ thuộc peer)
| Trước | Sau | |
|---|---|---|
engines.node | >=18.17.0 | ^18.18.0 || ^19.8.0 || >= 20.0.0 |
peerDependencies.react | ^18.2.0 | ^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0 |
peerDependencies.react-dom | ^18.2.0 | ^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0 |
peerDependencies.@playwright/test | ^1.41.2 | ^1.51.1 |
peerDependencies.babel-plugin-react-compiler | — | * |
Export mới (25)
| import | export | kind |
|---|---|---|
next | NextAdapter | interface |
next | Instrumentation | namespace |
next/link | useLinkStatus | variable |
next/cache | unstable_cacheTag | variable |
next/cache | unstable_cacheLife | function |
next/cache | unstable_expireTag | variable |
next/cache | unstable_expirePath | variable |
next/server | after | variable |
next/server | connection | variable |
next/server | unstable_rootParams | variable |
next/server | UnsafeUnwrappedParams | variable |
next/server | UnsafeUnwrappedSearchParams | variable |
next/headers | UnsafeUnwrappedCookies | type |
next/headers | UnsafeUnwrappedHeaders | type |
next/headers | UnsafeUnwrappedDraftMode | type |
next/constants | WEBPACK_STATS | variable |
next/constants | AdapterOutputType | enum |
next/constants | DYNAMIC_CSS_MANIFEST | variable |
next/constants | DEV_CLIENT_MIDDLEWARE_MANIFEST | variable |
next/constants | TURBOPACK_CLIENT_BUILD_MANIFEST | variable |
next/constants | TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST | variable |
next/navigation | forbidden | function |
next/navigation | unauthorized | function |
next/navigation | unstable_rethrow | variable |
next/navigation | unstable_isUnrecognizedActionError | function |
Câu hỏi thường gặp
Nâng cấp next từ 14 lên 15 có những thay đổi không tương thích nào?
Giữa next 14.2.35 và 15.5.27, Vigia tìm thấy 4 export bị xóa, 10 chữ ký thay đổi và 16 thành viên lớp hoặc interface bị xóa hay thay đổi.
Những gì bị ngừng hỗ trợ trong next 15?
5 export hoặc thành viên mới bị đánh dấu ngừng hỗ trợ trong next 15.5.27.
Dành cho tác tử
GET https://vigia.coredls.cloud/v1/packages/npm/next/upgrade?from=14.2.35&to=15.5.27