Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-native-web Server API Support #2631

Closed
1 task done
JegatheeshSelvam opened this issue Jan 24, 2024 · 1 comment
Closed
1 task done

react-native-web Server API Support #2631

JegatheeshSelvam opened this issue Jan 24, 2024 · 1 comment
Labels
enhancement Requires extension or creation of new React Native API

Comments

@JegatheeshSelvam
Copy link

Is there an existing request?

  • I have searched for this request

Describe the feature request

Please help me

How to configure my project:-

Link:- https://necolas.github.io/react-native-web/docs/rendering/#server-api

=============================================================================
Server API:-

Server-side rendering to HTML is supported using AppRegistry:

import App from './src/App';
import ReactDOMServer from 'react-dom/server';
import { AppRegistry } from 'react-native-web';

// register the app
AppRegistry.registerComponent('App', () => App);

// prerender the app
const { element, getStyleElement } = AppRegistry.getApplication('App', { initialProps });
// first the element
const html = ReactDOMServer.renderToString(element);
// then the styles (optionally include a nonce if your CSP policy requires it)
const css = ReactDOMServer.renderToStaticMarkup(getStyleElement({ nonce }));

// example HTML document string
const document = `

${css}
${html}
<script nonce="${nonce}" src="${bundlePath}"></script>

============================================================================

Example code or GitHub link is useful for me.

Eagerly waiting for your support.

@JegatheeshSelvam JegatheeshSelvam added the enhancement Requires extension or creation of new React Native API label Jan 24, 2024
@necolas
Copy link
Owner

necolas commented Jan 24, 2024

The code example is in the docs. Sorry, I can't provide further support if you're not familiar with server development and debugging issues

@necolas necolas closed this as completed Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Requires extension or creation of new React Native API
Projects
None yet
Development

No branches or pull requests

2 participants