Installation
This guide covers detailed installation instructions for BlocksWeb, including different setup methods and configuration options.
System Requirements
Before installing BlocksWeb, ensure your system meets these requirements:
- Node.js: Version 18.0.0 or higher
- npm: Version 9.0.0 or higher (or yarn/pnpm equivalent)
- Operating System: Windows, macOS, or Linux
- Browser: Modern browser (Chrome, Firefox, Safari, Edge)
Installation Methods
There are three ways to install BlocksWeb:
- CLI Tool (Recommended for new projects)
- Manual Installation (For existing projects)
- Clone Example (For learning)
Method 1: Using the CLI Tool (Recommended)
The easiest way to get started is with the BlocksWeb CLI:
npx create-blocksweb-app@latestCLI Options
The CLI will ask you several questions:
✔ What is your project named? … my-project
✔ Which template would you like to use?
› App Router (Recommended)
› Pages Router
› E-commerce Starter
› Marketing Site
✔ Would you like to use TypeScript? … Yes
✔ Would you like to install dependencies now? … YesWhat Gets Installed
The CLI creates a new project with:
- ✅ Next.js configured for BlocksWeb
- ✅ TypeScript setup
- ✅
@blocksweb/corepackage installed - ✅ Basic component examples
- ✅
blocksweb.config.tspre-configured - ✅ Tailwind CSS (optional)
- ✅ ESLint and Prettier
Method 2: Manual Installation
If you have an existing Next.js project, you can add BlocksWeb manually.
Step 1: Install the Package
npm install @blocksweb/core@latestOr with yarn:
yarn add @blocksweb/core@latestOr with pnpm:
pnpm add @blocksweb/core@latestStep 2: Install Peer Dependencies
BlocksWeb requires React 18+ and Next.js 11+:
npm install react@18 react-dom@18 next@15Step 3: Create Configuration File
Create blocksweb.config.ts in your project root:
import { IBlockswebComponent } from '@blocksweb/core';
export const editorComponents: IBlockswebComponent[] = [];
export const settings = {
editorComponents,
scripts: [],
};Step 4: Set Up Next.js (App Router)
If using App Router, create app/[[...path]]/page.tsx:
import { BlockswebProvider, Canvas } from '@blocksweb/core/client';
import { settings } from '@/blocksweb.config';
export default function Page({ params }: { params: { path?: string[] } }) {
const path = params.path ? '/' + params.path.join('/') : '/';
return (
<BlockswebProvider settings={settings}>
<Canvas path={path} />
</BlockswebProvider>
);
}Step 5: Set Up Next.js (Pages Router)
If using Pages Router, create pages/[[...path]].tsx:
import { BlockswebProvider, Canvas } from '@blocksweb/core/client';
import { settings } from '@/blocksweb.config';
import { GetServerSideProps } from 'next';
export default function Page({ path }: { path: string }) {
return (
<BlockswebProvider settings={settings}>
<Canvas path={path} />
</BlockswebProvider>
);
}
export const getServerSideProps: GetServerSideProps = async (context) => {
const path = context.params?.path
? '/' + (context.params.path as string[]).join('/')
: '/';
return {
props: { path },
};
};Step 6: Add Environment Variables
Create .env.local:
BLOCKSWEB_API_KEY=your_api_key_here
BLOCKSWEB_WORKSPACE_ID=your_workspace_id_hereStep 7: Import Styles
In your root layout (app/layout.tsx or pages/_app.tsx), import BlocksWeb styles:
import '@blocksweb/core/style.css';Method 3: Clone Example Project
Clone one of our example projects to get started:
# Marketing site example
git clone https://github.com/blockswebnl/blocksweb-example-marketing.git
cd blocksweb-example-marketing
npm install
# E-commerce example
git clone https://github.com/blockswebnl/blocksweb-example-ecommerce.git
cd blocksweb-example-ecommerce
npm install
# Blog example
git clone https://github.com/blockswebnl/blocksweb-example-blog.git
cd blocksweb-example-blog
npm installGetting Your API Key
BlocksWeb requires an API key to function. Here's how to get one:
1. Create an Account
Go to https://cloud.blocksweb.nl and sign up for a free account.
2. Create a Workspace
After signing in:
- Click "Create New Workspace"
- Enter a workspace name (e.g., "My Website")
- Choose your plan (Free tier available)
3. Get Your Credentials
In the workspace dashboard:
- Go to Settings → API Keys
- Copy your API Key
- Copy your Workspace ID
4. Add to Environment Variables
Add these to your .env.local file:
BLOCKSWEB_API_KEY=bw_live_abc123...
BLOCKSWEB_WORKSPACE_ID=ws_123456...Important
- Keep your API key secret
- Never commit
.env.localto version control - Add
.env.localto your.gitignorefile
Verifying Installation
After installation, verify everything is working:
1. Start Development Server
npm run dev2. Open Browser
Navigate to http://localhost:3000
3. Check for Sign-In Page
You should see the BlocksWeb sign-in page. If you see an error, check:
- API key is correct in
.env.local .env.localis in the project root- You restarted the dev server after adding environment variables
4. Sign In
Use your BlocksWeb account credentials to sign in. You should see the empty editor.
TypeScript Configuration
For the best experience, update your tsconfig.json:
{
"compilerOptions": {
"target": "ES2020",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}Optional: Install Tailwind CSS
BlocksWeb works great with Tailwind CSS for styling:
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -pConfigure tailwind.config.js:
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
'./components/**/*.{js,ts,jsx,tsx,mdx}',
'./app/**/*.{js,ts,jsx,tsx,mdx}',
],
theme: {
extend: {},
},
plugins: [],
}Add Tailwind directives to your CSS:
/* app/globals.css or styles/globals.css */
@tailwind base;
@tailwind components;
@tailwind utilities;Next Steps
Now that BlocksWeb is installed, you're ready to:
- Create Your First Component - Build a simple component
- Understand Project Structure - Learn the file organization
- Explore Components & Schema - Deep dive into architecture
Troubleshooting
Module Not Found Error
If you see Cannot find module '@blocksweb/core':
# Clear node_modules and reinstall
rm -rf node_modules package-lock.json
npm installAPI Key Error
If you see "Invalid API key":
- Check the key is correct in
.env.local - Ensure there are no extra spaces
- Verify the workspace ID matches
TypeScript Errors
If you see TypeScript errors:
# Install type definitions
npm install --save-dev @types/react @types/nodeNext.js Version Compatibility
BlocksWeb supports Next.js 11-15. If you're using an older version:
npm install next@latestUpgrade Guide
To upgrade BlocksWeb to the latest version:
npm install @blocksweb/core@latestCheck the changelog for breaking changes.
Need Help?
If you encounter issues:
- Check the Troubleshooting Guide
- Visit our GitHub Issues
- Join our Discord Community