Upgrading to 0.15.0

If you haven’t upgraded to 0.14.0 please read the upgrading guide.

Add ReactRuntimeProvider to your Next.js Custom App

If you don’t have a Custom App, you’ll need to add one. Then wrap it with ReactRuntimeProvider and pass your runtime instance to it.

pages/_app.tsx
1import { runtime } from "../../../../makeswift/runtime"
2import { ReactRuntimeProvider } from "@makeswift/runtime/next"
3import type { AppProps } from "next/app"
4
5export default function App({ Component, pageProps }: AppProps) {
6 return (
7 <ReactRuntimeProvider runtime={runtime}>
8 <Component {...pageProps} />
9 </ReactRuntimeProvider>
10 )
11}

Remove runtime prop from Page component

pages/[[...path]].tsx
1import { Page as MakeswiftPage } from '@makeswift/runtime/next'
2import { runtime } from '../../../../makeswift/runtime'
3
4/* ... */
5
6export default function Page({ snapshot }: Props) {
7- return <MakeswiftPage snapshot={snapshot} runtime={runtime} />
8+ return <MakeswiftPage snapshot={snapshot} />
9}

Use React.lazy instead of next/dynamic for code-splitting

makeswift/components.tsx
1import { runtime } from '../../../../makeswift/runtime'
2- import dynamic from 'next/dynamic'
3- import { forwardNextDynamicRef } from '@makeswift/runtime/next'
4+ import { lazy } from 'react'
5
6
7runtime.registerComponent(
8- forwardNextDynamicRef(patch =>
9- dynamic(() => patch(import('./Button').then(({ Button }) => Button)))
10- )
11+ lazy(() => import('./Button')),
12 { type: 'Button', label: 'Button', props: {} }
13)

Here is the link to the official release notes.