Based on the knowledge sources provided, there isn't a direct way to access the updateResult from the NextResponse.json in your Page.tsx after a redirect. The NextResponse.json is typically used to send a JSON response from an API route, and it's not directly accessible on the client-side or in a Next.js page component.
However, you can use a state management solution like Redux to store the updateResult and then access it in your Page.tsx. In the provided knowledge sources, there's an example of using Redux in a Next.js application. Here's the relevant code:
import store from '../../../redux/store';
import { getPageProfile } from '../../../redux/reducers/pageProfile';
async function Page({ params }) {
const user = getUser(cookies());
const headersReq = getCommonHeaders(headers(), user, true);
await store.dispatch(getPageProfile({
headers: headersReq,
userUrl: params.userUrl,
}));
const data = await store.getState().pageProfile;
if (data.error) {
throw new Error(data.error);
}
return (
<Profile
{...data}
userUrl={params.userUrl}
user={user}
/>
);
}
In this example, the store.dispatch method is used to dispatch an action that fetches some data (in this case, a user's profile), and then store.getState is used to access the fetched data.
You could follow a similar approach in your application: dispatch an action that fetches the updateResult from your API route, store it in your Redux store, and then access it in your Page.tsx using store.getState.
Please note that this approach requires setting up Redux in your Next.js application. If you're not already using Redux, you might need to install it and configure it in your application.