Skip to content

Instantly share code, notes, and snippets.

@lubieowoce
Last active March 21, 2024 09:01
Show Gist options
  • Save lubieowoce/06198859dd2cb13687b54b002cd8ac30 to your computer and use it in GitHub Desktop.
Save lubieowoce/06198859dd2cb13687b54b002cd8ac30 to your computer and use it in GitHub Desktop.
Extract the RSC payload from the HTML of a Next.js site
(() => {
const env = { self: {} };
const chunks = Array.from(document.body.querySelectorAll("script"))
.filter((s) => !!s.textContent && s.textContent.includes("self.__next_f"))
.forEach((s) => new Function("self", s.textContent)(env.self));
return env.self.__next_f
.filter((c) => c[0] === 1)
.map((c) => c[1])
.join("");
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment