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

[labs/nextjs] Add Next.js plugin for Lit SSR #3613

Merged
merged 7 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/happy-insects-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@lit-labs/nextjs': minor
---

Initial release of `@lit-labs/nextjs` package.

This package contains a plugin for Next.js that enables deep server rendering of Lit components.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ packages/labs/motion/index.*
packages/labs/motion/animate.*
packages/labs/motion/position.*
packages/labs/motion/animate-controller.*
packages/labs/nextjs/index.*

packages/labs/observers/development/
packages/labs/observers/test/
packages/labs/observers/node_modules/
Expand Down
6 changes: 0 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,6 @@
"rules": {
"import/no-extraneous-dependencies": "off"
}
},
{
"files": ["examples/**"],
"rules": {
"import/extensions": "off"
}
}
]
}
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ packages/labs/motion/index.*
packages/labs/motion/animate.*
packages/labs/motion/position.*
packages/labs/motion/animate-controller.*
packages/labs/nextjs/index.*

packages/labs/observers/development/
packages/labs/observers/test/
packages/labs/observers/node_modules/
Expand Down
1 change: 1 addition & 0 deletions examples/nextjs/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"root": true,
"extends": "next/core-web-vitals"
}
5 changes: 2 additions & 3 deletions examples/nextjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
This is a barebones demonstration of a Web Component authored with Lit working
in a Next.js project. You can also see an example of `@lit-labs/react` usage.

These components are shallowly rendered on the server, i.e. only the host
element tag will be server-rendered. When client-side JS is loaded, the
components will be upgraded with its contents rendered, and become interactive.
It uses the plugin from `@lit-labs/nextjs` to enable deep server rendering of
Lit components.
4 changes: 3 additions & 1 deletion examples/nextjs/next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const withLitSSR = require('@lit-labs/nextjs')();

/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
};

module.exports = nextConfig;
module.exports = withLitSSR(nextConfig);
3 changes: 2 additions & 1 deletion examples/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
"lint": "next lint"
},
"dependencies": {
"@lit-labs/nextjs": "file:../../packages/labs/nextjs",
"@lit-labs/react": "file:../../packages/labs/react",
"@types/node": "18.11.11",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.9",
"eslint": "8.29.0",
"eslint-config-next": "13.0.6",
"@lit-labs/react": "file:../../packages/labs/react",
"lit": "file:../../packages/lit",
"next": "13.0.6",
"react": "18.2.0",
Expand Down
1 change: 0 additions & 1 deletion examples/nextjs/src/simple-greeter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ declare global {
'simple-greeter': SimpleGreeter;
}

// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'simple-greeter':
Expand Down