Common Issues and Solutions
This guide covers the most common issues developers encounter when working with BlocksWeb and how to resolve them.
Installation & Setup Issues
"Cannot find module '@blocksweb/core'"
Problem: TypeScript or Node cannot find the BlocksWeb package.
Solutions:
# 1. Reinstall dependencies
rm -rf node_modules package-lock.json
npm install
# 2. Clear Next.js cache
rm -rf .next
# 3. Verify package is installed
npm list @blocksweb/core
# 4. Check package.json
cat package.json | grep blockswebIf the package isn't listed, install it:
npm install @blocksweb/core@latest"Invalid API Key" Error
Problem: BlocksWeb cannot authenticate with the API.
Checklist:
- Check
.env.localexists in project root - Verify variable names are correct:bash
BLOCKSWEB_API_KEY=bw_live_... BLOCKSWEB_WORKSPACE_ID=ws_... - No extra spaces around the
=sign - Restart dev server after adding variables:bash
# Stop server (Ctrl+C), then: npm run dev - Verify API key is valid in BlocksWeb Dashboard
Environment Variables Not Loading
Problem: Environment variables are undefined in your code.
Common causes:
1. Server vs Client Variables
// ❌ Won't work - server-only variable on client
'use client';
const apiKey = process.env.BLOCKSWEB_API_KEY; // undefined
// ✅ Works - use NEXT_PUBLIC_ prefix for client
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL;2. File location
.env.local must be in project root:
my-project/
├── .env.local ✅ Correct
├── app/
│ └── .env.local ❌ Wrong location
└── package.json3. Git-ignored
Make sure .env.local is in .gitignore:
# Environment files
.env.local
.env.*.localComponent Issues
Component Not Appearing in Editor
Problem: Your component doesn't show up in the "Add Block" menu.
Checklist:
Component is exported as default:
typescriptexport default MyComponent; // ✅ export const MyComponent = ...; // ❌Schema is attached:
typescriptMyComponent.schema = { displayName: 'My Component', options: [] }; // ✅Component is registered:
typescript// blocksweb.config.ts import MyComponent from './components/MyComponent'; export const editorComponents = [ MyComponent, // ✅ ];Browser cache cleared: Hard refresh (Ctrl+Shift+R / Cmd+Shift+R)
No TypeScript errors: Run
npm run type-check
"Cannot read property 'schema' of undefined"
Problem: Component schema is not properly attached.
Solution:
Make sure schema is attached before export:
const MyComponent: IBlockswebComponent = () => {
return <div>Content</div>;
};
// ✅ Attach schema BEFORE export
MyComponent.schema = {
displayName: 'My Component',
options: []
};
export default MyComponent;Don't do this:
// ❌ Wrong - exporting before attaching schema
export default MyComponent;
MyComponent.schema = {
displayName: 'My Component',
options: []
};Props Not Updating in Real-Time
Problem: Changes in the editor don't reflect in the component.
Checklist:
Prop names match schema:
typescript// Schema { type: 'text', name: 'title', ... } // Component props const MyComponent = ({ title }) => { // ✅ Names match return <h1>{title}</h1>; };Using props, not hardcoded values:
typescript// ✅ Good - uses prop <h1>{title}</h1> // ❌ Bad - hardcoded <h1>Hardcoded Title</h1>Component is not memoized incorrectly:
typescript// ❌ Bad - will not re-render on prop changes const MyComponent = React.memo(({ title }) => { return <h1>{title}</h1>; }, () => true); // Always returns true, never re-renders // ✅ Good - proper memoization const MyComponent = React.memo(({ title }) => { return <h1>{title}</h1>; });
TypeScript Errors
"Type 'IBlockswebComponent' is not assignable to type 'FunctionComponent'"
Problem: Type mismatch between BlocksWeb component and React component.
Solution:
Use the IBlockswebComponent type correctly:
import { IBlockswebComponent } from '@blocksweb/core';
// ✅ Correct
const MyComponent: IBlockswebComponent<MyProps> = (props) => {
return <div>...</div>;
};
// ❌ Wrong
const MyComponent: React.FC<MyProps> = (props) => {
return <div>...</div>;
};"Property 'schema' does not exist on type..."
Problem: TypeScript doesn't recognize the schema property.
Solution:
Make sure you're using IBlockswebComponent type:
import { IBlockswebComponent } from '@blocksweb/core';
const MyComponent: IBlockswebComponent = () => { // ✅ Has schema property
return <div>...</div>;
};
MyComponent.schema = { // Now TypeScript is happy
displayName: 'My Component',
options: []
};Data Fetching Issues
"Cannot read property 'data' of undefined"
Problem: Hook result is undefined.
Solution:
Always check loading and error states:
const { data, isLoading, error } = useCollection('products');
if (isLoading) return <div>Loading...</div>;
if (error) return <div>Error: {error.message}</div>;
if (!data) return null;
return <div>{data.map(...)}</div>;Infinite Re-renders
Problem: Component keeps re-rendering infinitely.
Common causes:
1. Creating objects in render:
// ❌ Bad - creates new object every render
const { data } = useCollection('products', {
where: { inStock: true } // New object every time
});
// ✅ Good - memoize the query
const query = useMemo(() => ({
where: { inStock: true }
}), []);
const { data } = useCollection('products', query);2. Missing dependencies:
// ❌ Bad
useEffect(() => {
fetchData();
}, []); // Missing fetchData dependency
// ✅ Good
const fetchData = useCallback(() => {
// Fetch logic
}, []);
useEffect(() => {
fetchData();
}, [fetchData]);"Failed to fetch" or Network Errors
Problem: Cannot connect to BlocksWeb API.
Checklist:
Check internet connection
Verify API URL:
bash# Default (cloud) BLOCKSWEB_API_URL=https://cloud.blocksweb.nl # Custom (self-hosted) BLOCKSWEB_API_URL=https://api.yoursite.comCheck CORS settings (if self-hosting)
Verify API key is valid in BlocksWeb dashboard
Check API status: Visit status.blocksweb.nl
Build & Deployment Issues
Build Fails with "Module parse failed"
Problem: Next.js cannot parse a file.
Common causes:
1. Missing file extension:
// ❌ Bad
import Hero from './components/Hero'; // Will look for .js/.jsx
// ✅ Good
import Hero from './components/Hero.tsx';2. Invalid TypeScript:
# Run type check to find errors
npm run type-check3. Missing dependencies:
# Reinstall dependencies
npm install"Cannot find module" in Production
Problem: Build works locally but fails in production.
Solutions:
1. Check file paths are correct:
// ❌ Bad - case-sensitive on Linux
import Hero from './Components/Hero'; // Capital C
// ✅ Good - match actual filename
import Hero from './components/Hero'; // Lowercase c2. Verify dependencies are in dependencies, not devDependencies:
{
"dependencies": {
"@blocksweb/core": "^2.0.0", // ✅
"react": "^18.0.0"
},
"devDependencies": {
"@types/react": "^18.0.0" // ✅ Types can be in devDependencies
}
}Out of Memory During Build
Problem: Build fails with "JavaScript heap out of memory".
Solutions:
1. Increase Node memory:
// package.json
{
"scripts": {
"build": "NODE_OPTIONS='--max-old-space-size=4096' next build"
}
}2. Optimize bundle size:
// next.config.js
module.exports = {
experimental: {
optimizeCss: true,
},
webpack: (config) => {
config.optimization.splitChunks = {
chunks: 'all',
};
return config;
},
};Editor Issues
Editor Not Loading
Problem: Editor shows blank screen or loading forever.
Checklist:
Check browser console for errors (F12)
Verify API key is correct
Clear browser cache:
- Chrome: Ctrl+Shift+Delete
- Firefox: Ctrl+Shift+Delete
- Safari: Cmd+Option+E
Try incognito/private mode
Check browser compatibility:
- Chrome 90+
- Firefox 88+
- Safari 14+
- Edge 90+
Changes Not Saving
Problem: Edits in the editor don't persist.
Solutions:
Check auto-save status in editor UI
Manually save: Use Cmd/Ctrl+S or click "Save" button
Check network tab (F12 → Network) for failed requests
Verify API key has write permissions
Check workspace plan hasn't exceeded limits
Performance Issues
Slow Page Load
Problem: Pages take too long to load.
Solutions:
1. Enable ISR (Incremental Static Regeneration):
// app/[[...path]]/page.tsx
export const revalidate = 60; // Revalidate every 60 seconds2. Optimize images:
import { Image } from '@blocksweb/core/client';
// Images are automatically optimized
<Image propName="hero" asset={heroImage} alt="Hero" />3. Use dynamic imports:
import dynamic from 'next/dynamic';
const HeavyComponent = dynamic(() => import('./HeavyComponent'), {
loading: () => <div>Loading...</div>,
});4. Enable caching:
// next.config.js
module.exports = {
async headers() {
return [
{
source: '/:path*',
headers: [
{
key: 'Cache-Control',
value: 's-maxage=60, stale-while-revalidate',
},
],
},
];
},
};Large Bundle Size
Problem: JavaScript bundle is too large.
Solutions:
1. Analyze bundle:
npm install -D @next/bundle-analyzer// next.config.js
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
module.exports = withBundleAnalyzer({});ANALYZE=true npm run build2. Use tree shaking:
// ✅ Good - imports only what you need
import { usePage } from '@blocksweb/core/client';
// ❌ Bad - imports everything
import * as Blocksweb from '@blocksweb/core/client';3. Lazy load components:
const ProductGrid = dynamic(() => import('@/components/ProductGrid'));Getting More Help
If you're still stuck:
Check Debug Mode: Enable debug logging:
typescript// blocksweb.config.ts export const settings = { debug: true, // Enable debug logs // ... };Search GitHub Issues: github.com/blockswebnl/blocksweb/issues
Ask on Discord: discord.gg/blocksweb
Contact Support: support@blocksweb.nl
Next Steps
- Installation Guide - Detailed setup instructions
- BlocksWeb Configuration - Configure your application
- Quick Start - Get started in 5 minutes