Skip to content

[labs/nextjs] A plugin for Next.js to integrate Lit SSR #3589

@augustjk

Description

@augustjk

Should this be an RFC?

  • This is not a substantial change

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions