Skip to content

Releases: apollographql/apollo-client-nextjs

v0.11.2: export additional `PreloadQuery`-related types

12 Jun 16:03
Compare
Choose a tag to compare

What's Changed

  • export PreloadQueryComponent and PreloadQueryProps types by @phryneas in #315

Full Changelog: v.0.11.1...v.0.11.2

v0.11.1: type fix for `PreloadQuery`

10 Jun 09:43
Compare
Choose a tag to compare

This release just fixes the TypeScript type of PreloadQuery

What's Changed

  • Update README links to point to non-experimental hooks links by @jer-k in #309
  • Use \ instead of double spaces to add line breaks by @jer-k in #310
  • more explicit PreloadQuery return type by @phryneas in #313

New Contributors

Full Changelog: v.0.11.0...v.0.11.1

v0.11.0: Prefetching in RSC, renaming exports, Next.js 15, less transported data, `@apollo/client-react-streaming/stream-utils`

29 May 11:06
Compare
Choose a tag to compare

Prefetching queries for Client Components in RSC

Calling registerApolloClient in RSC now also returns a PrefetchQuery component that can be used to prefetch queries in RSC to seed the Client Component cache.

Usage looks like

<PreloadQuery
  query={QUERY}
  variables={{
    foo: 1,
  }}
>
  <Suspense fallback={<>loading</>}>
    <ClientChild />
  </Suspense>
</PreloadQuery>

Client Components further down in the component tree can continue using useSuspenseQuery with the same QUERY to retrieve that data.

"use client";

import { useSuspenseQuery } from "@apollo/client";
// ...

export function ClientChild() {
  const { data } = useSuspenseQuery(QUERY);
  return <div>...</div>;
}

This also works with QueryRefs for usage with useReadQuery in Client Components.

For more details, see the new documentation at
https://github.com/apollographql/apollo-client-nextjs/tree/main?tab=readme-ov-file#preloading-data-in-rsc-for-usage-in-client-components

Renamed exports

In the past, the @apollo/experimental-nextjs-app-support package had two entry points, /rsc and /ssr.
This has caused a lot of confusion, and both entry points have been moved together into the base entry point, @apollo/experimental-nextjs-app-support.

On top of that, the Apollo Client React hooks (useQuery, useSuspenseQuery, etc.) no longer need to be imported from @apollo/experimental-nextjs-app-support, but they can be imported directly from @apollo/client now, while still being streaming-compatible.

Also, a few exports have been renamed:

  • NextSSRApolloClient -> ApolloClient
  • NextSSRInMemoryCache -> InMemoryCache
  • resetNextSSRApolloSingletons -> resetApolloClientSingletons

The old entry points with the old exports still exist and each of them has a @deprecated docblock explaining the new import to use.

Next.js 15 support

next@15-rc has been added to the peerDependencies, so this package can now be used with Next.js 15.

Thank you for the PR, @nphmuller!

Less transported data

In the past, we used the superjson package to serialize data to be transported from streaming SSR into the browser.
This package is great to allow values like undefined, circular references, and built-in class instances, like Dates.
Unfortunately, though, this adds a lot of metadata to the transported data.

Since the data we need to transport is already JSON-serializable and we only need a bit of extra handling for undefined, the SuperJSON dependency has been replaced with a more custom approach.
This considerably reduces the amount of data transported.
If you have custom non-serializable data that needs to be transported, you can provide custom stringify and revive functions.

On top of that, we now transport a minified version of the Query, which saves additional data.

@apollo/client-react-streaming/stream-utils

We have added a new entry point, @apollo/client-react-streaming/stream-utils, which exports helper functions you can use to integrate Apollo Client with custom streaming SSR setups with renderToReadableStream and renderToPipeableStream, e.g., in Vite.

We are still working on documentation for this feature, but you can already take a peek at https://deploy-preview-11807--apollo-client-docs.netlify.app/ssr-and-rsc/custom-streaming-ssr.

What's Changed

New Contributors

Full Changelog: v.0.10.1...v.0.11.0

v.0.10.1 Allow using the browser build of `ApolloNextAppProvider` outside of Next.js, e.g. for tests.

08 May 13:30
Compare
Choose a tag to compare

What's Changed

  • Allow using the browser build of ApolloNextAppProvider outside of Next.js, e.g. for tests. by @phryneas in #284

Full Changelog: v.0.10.0...v.0.10.1

v.0.10.0: optimize hydration render, prevent common error scenarios

04 Apr 16:08
Compare
Choose a tag to compare

What's Changed

  • 0.10.0 (1) - Throw error when passing arguments into getClient. by @phryneas in #203
  • 0.10.0 (2) - Warn if makeClient returns the same client for multiple requests. by @phryneas in #205
  • 0.10.0 (3) switch rehydration mismatch protection to useSyncExternalStore by @phryneas in #207
  • 0.10.0 (4) default connectToDevTools to false in RSC and SSR builds by @phryneas in #271

Full Changelog: v.0.9.2...v.0.10.0

v.0.9.2: Fix support for streaming in Edge functions

03 Apr 08:29
Compare
Choose a tag to compare

This release adds the "edge-light" exports condition to support export const runtime = "edge".

v.0.9.1: bugfix release

27 Mar 15:55
Compare
Choose a tag to compare

This release fixes a bug where in case a simulated query had to rerun in the browser (e.g. when the stream closed too soon), documentTransforms were not applied to that browser-side query.

v.0.9.0: separate builds, no more need for special hook imports, new transport mechanism

22 Mar 10:26
c8eac3d
Compare
Choose a tag to compare

This version introduces four big changes:

  • The package is now split up into @apollo/client-react-streaming for non-Next-logic and @apollo/experimental-nextjs-app-support. This means that the streaming approach can also be used by other frameworks like Redwood or hand-written setups with renderTo*Stream.
    As a user of @apollo/experimental-nextjs-app-support you should not notice this.
  • The packages have a new bundle setup and ship different builds for RSC, SSR and the browser. This should result in reduced bundle sizes.
  • The data transport mechanism has been reworked and you should now see less data transported over the wire.
  • You now don't need to import hooks from @apollo/experimental-nextjs-app-support anymore - the hooks from @apollo/client will work as you'd expect them to.

This release requires you to update your Apollo Client version to at least 3.9.6!

What's Changed

  • Removing confusing installation language in README.md by @spenweb in #187
  • chore(deps): update yarn to v4.1.0 by @svc-secops in #190
  • separate transport-specific streaming logic out by @phryneas in #189
  • split up into two packages by @phryneas in #193
  • registerApolloClient: allow for async makeClient function by @phryneas in #204
  • 0.9.0 (1) - adjust package shapes by @phryneas in #208
  • 0.9.0 (2) - wrap hook functionality from ApolloClient instance by @phryneas in #216
  • 0.9.0 (3) - add integration test with experimentally patched React version by @phryneas in #219
  • 0.9.0 (4) - Add integration test for vitejs + streaming by @phryneas in #198
  • Use Relative-CI to detect size changes in the Next.js integration test build. by @phryneas in #225
  • update Apollo Client version to 3.9.6 by @phryneas in #236
  • 0.9.0 (7) - Changes to Data Transport by @phryneas in #223
  • add size-limit workflow by @phryneas in #241
  • 0.9.0 (8) documentation updates and "branded" error messages by @phryneas in #240
  • [chore] Update Docs by @github-actions in #243
  • Bump version to 0.9.0 by @github-actions in #247

New Contributors

  • @spenweb made their first contribution in #187
  • @github-actions made their first contribution in #243

Full Changelog: v.0.8.0...v.0.9.0

0.8.0: drop workarounds for compat with Apollo Client 3.8, bump dependency to 3.9

01 Feb 14:04
88dc5b9
Compare
Choose a tag to compare

This version drops the workarounds for this package to work with both AC 3.8 and 3.9 and bumps the minimum peerDependency version to 3.9.

0.7.1: update `peerDependencies` for Apollo Client 3.9

01 Feb 11:07
Compare
Choose a tag to compare

This release adds ^3.9.0 to the list of @apollo/client versions in peerDependencies.