Skip to content

Commit 38b709c

Browse files
committed
feat: update web client integrations to match starter configs
- Enhanced Vite config with detailed topLevelAwait options - Improved Next.js webpack config with Nimiq optimizations - Added comprehensive Cloudflare Workers integration - Added quick start templates for all integrations - Updated navigation to include Cloudflare Workers
1 parent 8862006 commit 38b709c

File tree

4 files changed

+431
-15
lines changed

4 files changed

+431
-15
lines changed

.vitepress/theme.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const themeConfig = {
3333
{ text: 'Vite', link: '/web-client/integrations/vite', icon: 'i-logos:vitejs gray group-hocus:filter-none' },
3434
{ text: 'Nuxt', link: '/web-client/integrations/nuxt', icon: 'i-logos:nuxt-icon gray group-hocus:filter-none' },
3535
{ text: 'Next.js', link: '/web-client/integrations/NextJS', icon: 'i-logos:nextjs-icon gray group-hocus:filter-none' },
36+
{ text: 'Cloudflare Workers', link: '/web-client/integrations/cloudflare', icon: 'i-logos:cloudflare-icon gray group-hocus:filter-none' },
3637
{ text: 'ESM', link: '/web-client/integrations/ESM', icon: 'i-logos:javascript gray group-hocus:filter-none' },
3738
],
3839
},

web-client/integrations/NextJS.md

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
Integrate Nimiq Web Client with Next.js for production-ready React blockchain applications.
44

5+
## Quick Start with Template
6+
7+
Get started instantly with our pre-configured Next.js starter:
8+
9+
```bash
10+
npx degit onmax/nimiq-starter/starters/next-js my-nimiq-app
11+
cd my-nimiq-app && pnpm install && pnpm dev
12+
```
13+
514
## Installation
615

716
### Quick Start
@@ -18,39 +27,61 @@ Next.js supports WebAssembly out of the box, but you need to configure it for op
1827

1928
```javascript
2029
// next.config.js
30+
import path from 'node:path'
31+
2132
/** @type {import('next').NextConfig} */
2233
const nextConfig = {
23-
// Enable WebAssembly
2434
webpack: (config, { isServer }) => {
2535
// Enable WebAssembly
2636
config.experiments = {
2737
...config.experiments,
2838
asyncWebAssembly: true,
39+
topLevelAwait: true,
2940
}
3041

31-
// Handle .wasm files
42+
// Configure module rules for WebAssembly
3243
config.module.rules.push({
3344
test: /\.wasm$/,
3445
type: 'webassembly/async',
3546
})
3647

37-
// Optimize for client-side
38-
if (!isServer) {
39-
config.resolve.fallback = {
40-
...config.resolve.fallback,
48+
// Enhanced module resolution for @nimiq/core
49+
config.resolve = {
50+
...config.resolve,
51+
alias: {
52+
...config.resolve?.alias,
53+
'@nimiq/core': path.resolve('./node_modules/@nimiq/core/bundler/index.js'),
54+
},
55+
fallback: {
56+
...config.resolve?.fallback,
57+
path: false,
4158
fs: false,
42-
net: false,
43-
tls: false,
59+
},
60+
// Add .js extension for ESM imports
61+
extensions: [...(config.resolve?.extensions || []), '.js', '.mjs'],
62+
}
63+
64+
// Exclude @nimiq/core from optimization
65+
if (!isServer) {
66+
config.optimization = {
67+
...config.optimization,
68+
splitChunks: {
69+
...config.optimization?.splitChunks,
70+
cacheGroups: {
71+
...(config.optimization?.splitChunks)?.cacheGroups,
72+
nimiq: {
73+
test: /@nimiq/,
74+
name: 'nimiq',
75+
chunks: 'all',
76+
priority: 10,
77+
},
78+
},
79+
},
4480
}
4581
}
4682

4783
return config
4884
},
49-
// Enable experimental features
50-
experimental: {
51-
// Enable WebAssembly
52-
esmExternals: true,
53-
},
5485
}
5586

5687
module.exports = nextConfig

0 commit comments

Comments
 (0)