-
Notifications
You must be signed in to change notification settings - Fork 879
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
[labs/nextjs] A plugin for Next.js to integrate Lit SSR #3589
Comments
It would also be nice if we could add the template shadowroot polyfill for non-supported browsers. There may be a way to do this through the webpack config as well. Otherwise, users might need to add it to the bottom of the |
I don't think we should automatically include the polyfill, except possibly as some addition to an automatic polyfill injection that Next already has. |
My thought was that frameworks like Next tend to make things "just work", and frameworks like react don't require thinking about this problem. To match that experience, maybe automatic polyfill injection is something we should actually consider. Another thought is that to prevent the FOUC problem, we'll also want some easy-to-use way to block rendering until the polyfill has activated, as shown at https://github.com/lit/lit/tree/main/packages/labs/eleventy-plugin-lit#example-bootup-strategy |
As it is, we also get React hydration mismatch error if |
FWIW the Nuxt plugin includes the DSD polyfill for browsers that don't support it. https://github.com/prashantpalikhe/nuxt-ssr-lit/blob/main/src/runtime/plugins/shim.client.ts is included as a client-side plugin |
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 functionwithLitSsr
which 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.createElement
and also replace any runtime jsx transforms to use@lit-labs/ssr-react
instead.Alternatives considered:
jsxImportSource
orjsxFactory
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
The text was updated successfully, but these errors were encountered: