├── .gitignore
├── LICENSE.md
├── README.md
├── eslint.config.mjs
├── next.config.cjs
├── package.json
├── src
└── app
│ ├── favicon.ico
│ ├── globals.css
│ ├── layout.tsx
│ └── page.tsx
└── tsconfig.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 | package-lock.json
8 |
9 | # testing
10 | /coverage
11 |
12 | # next.js
13 | /.next/
14 | /out/
15 |
16 | # production
17 | /build
18 |
19 | # misc
20 | .DS_Store
21 | *.pem
22 |
23 | # debug
24 | npm-debug.log*
25 | yarn-debug.log*
26 | yarn-error.log*
27 |
28 | # local env files
29 | .env*.local
30 |
31 | # vercel
32 | .vercel
33 |
34 | # typescript
35 | *.tsbuildinfo
36 | next-env.d.ts
37 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 tldraw Inc.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | This repo contains a template for using [tldraw](https://github.com/tldraw/tldraw) with the [Next.js](https://nextjs.org/) framework.
9 |
10 | ## Local development
11 |
12 | Install dependencies with `yarn` or `npm install`.
13 |
14 | Run the development server with `yarn dev` or `npm run dev`.
15 |
16 | Open `http://localhost:3000/` in your browser to see the app.
17 |
18 | ## License
19 |
20 | This project is provided under the MIT license found [here](https://github.com/tldraw/nextjs-template/blob/main/LICENSE.md). The tldraw SDK is provided under the [tldraw license](https://github.com/tldraw/tldraw/blob/main/LICENSE.md).
21 |
22 | ## Trademarks
23 |
24 | Copyright (c) 2024-present tldraw Inc. The tldraw name and logo are trademarks of tldraw. Please see our [trademark guidelines](https://github.com/tldraw/tldraw/blob/main/TRADEMARKS.md) for info on acceptable usage.
25 |
26 | ## Distributions
27 |
28 | You can find tldraw on npm [here](https://www.npmjs.com/package/@tldraw/tldraw?activeTab=versions).
29 |
30 | ## Contribution
31 |
32 | Please see our [contributing guide](https://github.com/tldraw/tldraw/blob/main/CONTRIBUTING.md). Found a bug? Please [submit an issue](https://github.com/tldraw/tldraw/issues/new).
33 |
34 | ## Community
35 |
36 | Have questions, comments or feedback? [Join our discord](https://discord.tldraw.com/?utm_source=github&utm_medium=readme&utm_campaign=sociallink). For the latest news and release notes, visit [tldraw.dev](https://tldraw.dev).
37 |
38 | ## Contact
39 |
40 | Find us on Twitter/X at [@tldraw](https://twitter.com/tldraw).
41 |
--------------------------------------------------------------------------------
/eslint.config.mjs:
--------------------------------------------------------------------------------
1 | import { FlatCompat } from '@eslint/eslintrc'
2 | import js from '@eslint/js'
3 | import path from 'node:path'
4 | import { fileURLToPath } from 'node:url'
5 |
6 | const __filename = fileURLToPath(import.meta.url)
7 | const __dirname = path.dirname(__filename)
8 | const compat = new FlatCompat({
9 | baseDirectory: __dirname,
10 | recommendedConfig: js.configs.recommended,
11 | allConfig: js.configs.all,
12 | })
13 | export default [...compat.extends('next/core-web-vitals')]
14 |
--------------------------------------------------------------------------------
/next.config.cjs:
--------------------------------------------------------------------------------
1 | /** @type {import('next').NextConfig} */
2 | const nextConfig = {
3 | experimental: {
4 | serverComponentsExternalPackages: ['@tldraw/tldraw'],
5 | },
6 | }
7 |
8 | module.exports = nextConfig
9 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tldraw-nextjs-app-example",
3 | "version": "0.1.0",
4 | "private": true,
5 | "author": {
6 | "name": "tldraw GB Ltd.",
7 | "email": "hello@tldraw.com"
8 | },
9 | "homepage": "https://tldraw.dev",
10 | "license": "MIT",
11 | "scripts": {
12 | "dev": "next dev",
13 | "build": "next build",
14 | "start": "next start",
15 | "lint": "next lint"
16 | },
17 | "dependencies": {
18 | "@types/node": "20.3.1",
19 | "@types/react": "^18.3.18",
20 | "@types/react-dom": "^18.3.5",
21 | "eslint": "^9.13.0",
22 | "next": "14.1.1",
23 | "react": "^18.2.0",
24 | "react-dom": "^18.2.0",
25 | "tldraw": "3.13.1",
26 | "typescript": "5.1.3"
27 | },
28 | "devDependencies": {
29 | "@eslint/eslintrc": "^3.1.0",
30 | "@eslint/js": "^9.13.0"
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/app/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tldraw/nextjs-template/2315691be5adf54a5d0dba3e4b8a13b106e5f5b5/src/app/favicon.ico
--------------------------------------------------------------------------------
/src/app/globals.css:
--------------------------------------------------------------------------------
1 | @import url('https://fonts.googleapis.com/css2?family=Inter:wght@500;700&display=swap');
2 | @import url('tldraw/tldraw.css');
3 |
4 | body {
5 | font-family: 'Inter';
6 | overscroll-behavior: none;
7 | }
8 |
--------------------------------------------------------------------------------
/src/app/layout.tsx:
--------------------------------------------------------------------------------
1 | import './globals.css'
2 |
3 | export const metadata = {
4 | title: 'tldraw Next.js app template',
5 | description: 'An example of how to use tldraw in a Next.js app',
6 | }
7 |
8 | export default function RootLayout({ children }: { children: React.ReactNode }) {
9 | return (
10 |
11 | {children}
12 |
13 | )
14 | }
15 |
--------------------------------------------------------------------------------
/src/app/page.tsx:
--------------------------------------------------------------------------------
1 | 'use client'
2 | import { Tldraw } from 'tldraw'
3 |
4 | export default function Home() {
5 | return (
6 |
7 |