Should this be an RFC?
Which package is this a feature request for?
SSR (@lit-labs/ssr)
Description
Part of #2391 and depends on #3588
With @lit-labs/ssr-react package being the core implementation of integrating Lit SSR with React Server DOM, it would be good to have an easy way to configure a Next.js project with a plugin.
We could have a package @lit-labs/nextjs which exports function withLitSsr which can be used to create/wrap the users's next.config.js. This could look like https://github.com/vercel/next.js/blob/canary/packages/next-mdx/index.js
The plugin would add to the webpack config of the Next.js project to add side-effect imports to bundle entrypoints to monkey patch React.createElement and also replace any runtime jsx transforms to use @lit-labs/ssr-react instead.
Alternatives considered:
- Users could manually configure
jsxImportSource or jsxFactory depending on the runtime mode of the project. The problem with this is that it will not work with components made using @lit-labs/react, or other precompiled React components housing Lit components.
Alternatives and Workarounds
N/A
Should this be an RFC?
Which package is this a feature request for?
SSR (@lit-labs/ssr)
Description
Part of #2391 and depends on #3588
With
@lit-labs/ssr-reactpackage being the core implementation of integrating Lit SSR with React Server DOM, it would be good to have an easy way to configure a Next.js project with a plugin.We could have a package
@lit-labs/nextjswhich exports functionwithLitSsrwhich can be used to create/wrap the users'snext.config.js. This could look like https://github.com/vercel/next.js/blob/canary/packages/next-mdx/index.jsThe plugin would add to the webpack config of the Next.js project to add side-effect imports to bundle entrypoints to monkey patch
React.createElementand also replace any runtime jsx transforms to use@lit-labs/ssr-reactinstead.Alternatives considered:
jsxImportSourceorjsxFactorydepending on the runtime mode of the project. The problem with this is that it will not work with components made using@lit-labs/react, or other precompiled React components housing Lit components.Alternatives and Workarounds
N/A