Installation
Layr is distributed via npm and can be installed using any modern JavaScript package manager.
| Requirement | Version |
|---|
| Node.js | ≥18.0.0 |
| React | ^18.0.0 or ^19.0.0 |
| TypeScript (optional) | ≥5.0.0 recommended |
Layr has zero runtime dependencies. It only requires React as a peer dependency.
npm install @dynshift/layr
After installation, verify Layr is working correctly:
import { Container } from '@dynshift/layr';
export function App() {
return (
<Container width={200} height={100} color="#3b82f6">
<span>Layr is installed!</span>
</Container>
);
}
If the component renders without errors, the installation was successful.
Layr supports both ESM (ECMAScript Modules) and CommonJS out of the box. Your bundler will automatically select the correct format.
import { Container, Row, Column } from '@dynshift/layr';
const { Container, Row, Column } = require('@dynshift/layr');
5. TypeScript Configuration
Layr includes built-in TypeScript definitions. No additional `@types` packages are required.
5a. Automatic Type Detection
If your project uses TypeScript, types will be automatically resolved:
import { Container, ContainerProps } from '@dynshift/layr';
const MyContainer: React.FC<ContainerProps> = (props) => {
return <Container {...props} />;
};
5b. Recommended tsconfig.json
For optimal compatibility, ensure your tsconfig.json includes:
{
"compilerOptions": {
"moduleResolution": "bundler",
"esModuleInterop": true,
"jsx": "react-jsx",
"strict": true
}
}
Layr is fully tree-shakeable. Import only what you need, and unused components will be excluded from your production bundle.
import { Container, Row } from '@dynshift/layr';
import * as Layr from '@dynshift/layr';
7a. Install Specific Version
npm install @dynshift/layr@1.0.2
7b. Install Latest Version
npm install @dynshift/layr@latest
7c. Check Installed Version
8. Framework-Specific Setup
import { Container } from '@dynshift/layr';
export default function Page() {
return <Container width={300} height={200} color="#1a1a1a" />;
}
8b. Next.js (Pages Router)
import { Container } from '@dynshift/layr';
export default function Home() {
return <Container width={300} height={200} color="#1a1a1a" />;
}
import { Container } from '@dynshift/layr';
function App() {
return <Container width={300} height={200} color="#1a1a1a" />;
}
import { Container } from '@dynshift/layr';
function App() {
return <Container width={300} height={200} color="#1a1a1a" />;
}
import { Container } from '@dynshift/layr';
export default function Index() {
return <Container width={300} height={200} color="#1a1a1a" />;
}
Layr is not compatible with React Native. It is designed specifically for web applications and uses standard CSS layout primitives.
If you're building for React Native, use Flutter-style layout components like react-native-reanimated or stick with React Native's built-in layout system.
Layr is designed to be lightweight:
• Full library: ~12 KB (minified + gzipped)
• Single component (e.g., Container): ~3 KB (minified + gzipped)
• Zero runtime dependencies
You can analyze your bundle size using:
# Using webpack-bundle-analyzer
npm install --save-dev webpack-bundle-analyzer
# Using Vite
npm install --save-dev rollup-plugin-visualizer
11. CDN Usage (Not Recommended)
While Layr can be loaded from a CDN, we strongly recommend using a package manager for production applications.
<script src="https://unpkg.com/@dynshift/layr@1.0.2/dist/index.umd.js"></script>
Why not use a CDN?
• No tree-shaking (entire library is loaded)
• No TypeScript support
• Slower initial load time
• Version updates require manual changes
If you see Module not found: Can't resolve '@dynshift/layr':
1. Ensure the package is installed: npm list @dynshift/layr
2. Clear your node_modules and reinstall: rm -rf node_modules && npm install
3. Restart your development server
If TypeScript doesn't recognize Layr types:
1. Ensure TypeScript version is ≥5.0.0
2. Check that moduleResolution is set to "bundler" or "node16" in tsconfig.json
3. Restart your TypeScript server in your editor
12c. React Version Mismatch
If you see peer dependency warnings:
npm WARN @dynshift/layr@1.0.2 requires a peer of react@^18.0.0 || ^19.0.0
Install a compatible React version:
npm install @dynshift/layr@latest
Check the
Changelog for breaking changes between versions.
• Migration from Flutter — Learn the differences from Flutter's layout system
• TypeScript Setup — Configure advanced type checking