Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions packages/nextjs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
31 changes: 31 additions & 0 deletions packages/nextjs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# @m3e/nextjs

The `@m3e/nextjs` package provides idiomatic, typed dynamic imports in nextjs for M3E Web Components, exposing their properties, attributes, and native DOM events through a familiar React interface with full ref forwarding and client‑only compatibility.

The React bindings are client-only and must be used inside a `"use client"` an also works without this `"use client"` because Dynamic Import is Used boundary in your application.

To support Next.js and SSR, `@m3e/web` works with Lit's server-ready modules, and consumers only need to wrap their `next.config.js` with `withLitSSR` from `@lit-labs/nextjs`. This lets Next.js load the correct server build instead of evaluating browser code during rendering, so all `@m3e/web` elements render on the server and hydrate on the client without any extra setup.

## 🧪 Example

The following example demonstrates how to use the `M3eButton` React binding from `@m3e/nextjs/button`.

```tsx
"use client";

import { M3eButton, M3eButtonElement } from "@m3e/nextjs/button";
import {useRef} from "react";

export default function ClickExample() {
const buttonRef = useRef<M3eButtonElement>();
return <M3eButton onClick={() => console.log("Button clicked!")}>Click me</M3eButton>;
}
```

## 🤝 Contributing

See the root monorepo `CONTRIBUTING.md` for guidelines on contributing to this package.

## 📄 License

This package is licensed under the MIT License.
Empty file added packages/nextjs/app/globals.css
Empty file.
32 changes: 32 additions & 0 deletions packages/nextjs/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";

const geistSans = Geist({
variable: "--font-geist-sans",
subsets: ["latin"],
});

const geistMono = Geist_Mono({
variable: "--font-geist-mono",
subsets: ["latin"],
});

export const metadata: Metadata = {
title: "M3e for NEXTJS",
description: "This is a key library for next js powered by @m3e/react use only for the famous framework nextjs 16 app router",
};

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body className={`${geistSans.variable} ${geistMono.variable}`}>
{children}
</body>
</html>
);
}
Empty file.
5 changes: 5 additions & 0 deletions packages/nextjs/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default function Home() {
return (
<div>npm i @m3e/nextjs</div>
);
}
18 changes: 18 additions & 0 deletions packages/nextjs/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineConfig, globalIgnores } from "eslint/config";
import nextVitals from "eslint-config-next/core-web-vitals";
import nextTs from "eslint-config-next/typescript";

const eslintConfig = defineConfig([
...nextVitals,
...nextTs,
// Override default ignores of eslint-config-next.
globalIgnores([
// Default ignores of eslint-config-next:
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
]),
]);

export default eslintConfig;
8 changes: 8 additions & 0 deletions packages/nextjs/next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
/* config options here */
reactCompiler: true,
};

export default nextConfig;
Loading
Loading