How to use the @apollo/react-ssr.renderToStringWithData function in @apollo/react-ssr

To help you get started, we’ve selected a few @apollo/react-ssr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github letterpad / letterpad / client / server.js View on Github external
};

  const sheet = new ServerStyleSheet(); // <-- creating out stylesheet
  const clientApp = (
    
      
        
          
            
          
        
      
    
  );
  try {
    const content = await renderToStringWithData(clientApp);
    const initialState = client.extract();
    return {
      head: Helmet.renderStatic(),
      html: content,
      apolloState: initialState,
      sheet: sheet,
    };
  } catch (error) {
    console.log("error :", error);
  }
};
github letterpad / letterpad / src / client / server / app.tsx View on Github external
const sheet = new ServerStyleSheet(); // <-- creating out stylesheet
  const clientApp = (
    
      
        
          
            
              
            
          
        
      
    
  );
  try {
    const content = await renderToStringWithData(clientApp);
    const initialState = client.extract();
    return {
      head: Helmet.renderStatic(),
      html: content,
      initialData: { ...initialData, initialProps },
      apolloState: initialState,
      sheet: sheet,
    };
  } catch (error) {
    console.log("error :", error);
  }
};

@apollo/react-ssr

React Apollo server-side rendering utilities

MIT
Latest version published 4 years ago

Package Health Score

64 / 100
Full package analysis