A Next.js application exploring concepts from Daniel Shiffman's "The Nature of Code 2024 Ed." using p5.js
npm install
npm run dev
# localhost:3000vercel
# deploy
- Next.js 15.3 - React framework with App Router
- p5.js - Creative coding library
- TypeScript - Type-safe JavaScript
- Tailwind CSS - Utility-first CSS framework
- Vercel - Deployment platform
nature-of-code/
├── public/
├── src/
│ ├── app/ # Next.js App Router
│ │ ├── examples/ # Examples
│ │ ├── exercises/ # Practice exercises
│ │ └── page.tsx # Home page
│ └── components/
│ ├── P5Wrapper.tsx # p5.js integration
│ └── SketchLayout.tsx # Layout for sketches
All p5.js components use the 'use client' directive to ensure they only run in the browser. Dynamic imports are used to prevent server-side rendering (SSR) issues:
'use client';
import dynamic from 'next/dynamic';
const P5Wrapper = dynamic(() => import('@/components/P5Wrapper'), { ssr: false });
import SketchLayout from '@/components/SketchLayout';
🙏 Acknowledgements
- Daniel Shiffman for "The Nature of Code" book and concepts
- p5.js for the creative coding library
- Next.js for the React framework
- Vercel for deployment
- Create utility classes for common concepts like vectors, forces, etc.
- Create shared sketch components like particles, springs, etc.
- Use TypeScript interfaces for better code organization
- Add controls to sketches or implement a suitable library