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

Fix NextJS example #3540

Merged
merged 10 commits into from
Dec 4, 2023
Merged
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
2 changes: 2 additions & 0 deletions core/examples/luigi-example-next/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ yarn-error.log*

# vercel
.vercel

public/luigi-client.js
19 changes: 15 additions & 4 deletions core/examples/luigi-example-next/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ This is the NextJS-based sample application which runs with Luigi framework.

Due to the nature of NextJS's routing strategy, it is not possible to use `useHashRouting: false` in the Luigi Configuration. If you want to use path based routing, Luigi Core's index.html should be served separately.

>**NOTE**: Due to NextJS's server side nature, injecting Luigi Client in your pages is not straightforward, since Lugi Client relies on the window object only available at the client side. To resolve that, simply include the `luigi-client.js` file as the source of an HTML script as shown in the `home.js` file.
This will allow you to use Luigi Client as part of the window object of that micro frontend, for example: `window['LuigiClient']`

## Getting Started

First, install dependencies
Expand All @@ -14,12 +17,20 @@ First, install dependencies
npm install
```

Second, run the development server:
Second, build the NextJS app:

```bash
npm run build
```

Next, run the server:

```bash
npm run dev
# or
yarn dev
# for production mode
npm run start

# or for development mode
npm run dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
Expand Down
180 changes: 100 additions & 80 deletions core/examples/luigi-example-next/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions core/examples/luigi-example-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"copy:luigi-client": "cp node_modules/@luigi-project/client/luigi-client.js public",
"dev": "npm run copy:luigi-client && next dev",
"build": "next build && npm run copy:luigi-client",
"start": "next start"
},
"dependencies": {
"@luigi-project/client": "^2.2.1",
"@luigi-project/core": "^2.2.1",
"next": "13.4.4",
"@luigi-project/client": "^2.7.2",
"@luigi-project/core": "^2.7.2",
"next": "13.5.6",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
Loading