@prismetic/next-preview-core 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -29,7 +29,7 @@ import { PreviewProviders } from "@prismetic/next-preview-core";
29
29
  const isPreview = process.env.NEXT_PUBLIC_APP_ENV === "preview";
30
30
 
31
31
  return isPreview ? (
32
- <PreviewProviders>
32
+ <PreviewProviders refetchOnWindowFocus={true}>
33
33
  <YourPreviewLayoutFetcher locale={locale}>
34
34
  {children}
35
35
  </YourPreviewLayoutFetcher>
@@ -39,6 +39,11 @@ return isPreview ? (
39
39
  );
40
40
  ```
41
41
 
42
+ ### Best Practice: `refetchOnWindowFocus`
43
+ We highly recommend passing `refetchOnWindowFocus={true}` to `<PreviewProviders>`.
44
+ * **Seamless Editing**: When a content editor updates data in Strapi and tabs back to the Preview website, the current page will automatically and silently refetch the freshest data.
45
+ * **Performance Optimized**: The provider intelligently uses `{ refetchType: 'active' }`. It will **only** refetch the page currently visible on the screen, completely ignoring any background cache queries (such as those generated by link-hover prefetching). This eliminates wasteful GraphQL requests.
46
+
42
47
  ### `withLivePreview(WrappedComponent, fetcherFn, cacheKeyGenerator)`
43
48
 
44
49
  A Higher-Order Component that handles `useQuery`, loading/error states, and injects fetched data into your UI component.
@@ -82,6 +87,9 @@ export default async function LocaleHomePage({ params }) {
82
87
  }
83
88
  ```
84
89
 
90
+ ## Deployment
91
+ npm run build && npm version patch && npm publish --access public
92
+
85
93
  ## Build Commands
86
94
 
87
95
  | Command | Output |
package/dist/index.js CHANGED
@@ -50,7 +50,7 @@ function PreviewProviders({
50
50
  if (!refetchOnWindowFocus) return;
51
51
  const handleFocus = () => {
52
52
  if (document.visibilityState === "visible") {
53
- queryClient.invalidateQueries({ refetchType: "all" });
53
+ queryClient.invalidateQueries({ refetchType: "active" });
54
54
  }
55
55
  };
56
56
  document.addEventListener("visibilitychange", handleFocus);
package/dist/index.mjs CHANGED
@@ -24,7 +24,7 @@ function PreviewProviders({
24
24
  if (!refetchOnWindowFocus) return;
25
25
  const handleFocus = () => {
26
26
  if (document.visibilityState === "visible") {
27
- queryClient.invalidateQueries({ refetchType: "all" });
27
+ queryClient.invalidateQueries({ refetchType: "active" });
28
28
  }
29
29
  };
30
30
  document.addEventListener("visibilitychange", handleFocus);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismetic/next-preview-core",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Hybrid static/preview architecture for Next.js + Strapi projects",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -42,7 +42,7 @@ export function PreviewProviders({
42
42
 
43
43
  const handleFocus = () => {
44
44
  if (document.visibilityState === "visible") {
45
- queryClient.invalidateQueries({ refetchType: "all" });
45
+ queryClient.invalidateQueries({ refetchType: "active" });
46
46
  }
47
47
  };
48
48