Skip to content

Instantly share code, notes, and snippets.

@user24
Created May 8, 2024 11:33
Show Gist options
  • Save user24/9bd5be0a6a435eb7ac834ce2b6f394fd to your computer and use it in GitHub Desktop.
Save user24/9bd5be0a6a435eb7ac834ce2b6f394fd to your computer and use it in GitHub Desktop.
import { useEffect, useState } from 'react';
const ClientSideApp = ({ children }) => {
// Make Next OK with fully client-side rendering, as described in https://colinhacks.com/essays/building-a-spa-with-nextjs
const [render, setRender] = useState(false);
useEffect(() => setRender(true), []);
return render ? children : null;
};
function App ({ Component, pageProps }) {
return <ClientSideApp>
<Component {...pageProps} />
</ClientSideApp>;
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment