diff options
author | 2023-02-23 17:13:30 -0800 | |
---|---|---|
committer | 2023-02-23 17:13:30 -0800 | |
commit | f54300578b1edc7f67daddbfae29575cbf305264 (patch) | |
tree | 1437f3274122c011f879dca71f59a74d75a33fd0 /docs/dev/nextjs.md | |
parent | 5929daeeae1f528abab31979a0a28bc87a03b1f4 (diff) | |
download | bun-f54300578b1edc7f67daddbfae29575cbf305264.tar.gz bun-f54300578b1edc7f67daddbfae29575cbf305264.tar.zst bun-f54300578b1edc7f67daddbfae29575cbf305264.zip |
Add documentation (#2148)bun-v0.5.7
* Add documentation
* Tweaks
* Fixes
* Rearrange
* Update
Diffstat (limited to 'docs/dev/nextjs.md')
-rw-r--r-- | docs/dev/nextjs.md | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/docs/dev/nextjs.md b/docs/dev/nextjs.md new file mode 100644 index 000000000..92849c989 --- /dev/null +++ b/docs/dev/nextjs.md @@ -0,0 +1,33 @@ +To create a new Next.js app with bun: + +```bash +$ bun create next ./app +$ cd app +$ bun dev # start dev server +``` + +To use an existing Next.js app with bun: + +```bash +$ bun add bun-framework-next +$ echo "framework = 'next'" > bunfig.toml +$ bun bun # bundle dependencies +$ bun dev # start dev server +``` + +Many of Next.js’ features are supported, but not all. + +Here’s what doesn’t work yet: + +- `getStaticPaths` +- same-origin `fetch` inside of `getStaticProps` or `getServerSideProps` +- locales, zones, `assetPrefix` (workaround: change `--origin \"http://localhost:3000/assetPrefixInhere\"`) +- `next/image` is polyfilled to a regular `<img src>` tag. +- `proxy` and anything else in `next.config.js` +- API routes, middleware (middleware is easier to support, though! Similar SSR API) +- styled-jsx (technically not Next.js, but often used with it) +- React Server Components + +When using Next.js, Bun automatically reads configuration from `.env.local`, `.env.development` and `.env` (in that order). `process.env.NEXT_PUBLIC_` and `process.env.NEXT_` automatically are replaced via `--define`. + +Currently, any time you import new dependencies from `node_modules`, you will need to re-run `bun bun --use next`. This will eventually be automatic. |