Skip to content

Commit

Permalink
[labs/nextjs] Add Next.js plugin for Lit SSR (#3613)
Browse files Browse the repository at this point in the history
  • Loading branch information
augustjk committed Feb 28, 2023
1 parent b9c27c5 commit be18292
Show file tree
Hide file tree
Showing 17 changed files with 1,716 additions and 196 deletions.
7 changes: 7 additions & 0 deletions .changeset/happy-insects-fail.md
@@ -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
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
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
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
@@ -1,3 +1,4 @@
{
"root": true,
"extends": "next/core-web-vitals"
}
5 changes: 2 additions & 3 deletions examples/nextjs/README.md
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
@@ -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
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
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

0 comments on commit be18292

Please sign in to comment.