You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+6-62Lines changed: 6 additions & 62 deletions
Original file line number
Diff line number
Diff line change
@@ -13,20 +13,12 @@
13
13
14
14
This build plugin is a utility for enabling server-side rendering in Next.js on Netlify. It wraps your application in a tiny compatibility layer, so that pages can use Netlify Functions to be server-side rendered.
15
15
16
-
**TL;DR: You can enable SSR in your Next.js applications with 3 simple steps, listed [here](#setup)!**
17
-
18
16
## Table of Contents
19
17
20
18
-[Installation and Configuration](#installation-and-configuration)
21
-
-[Setup](#setup)
22
-
-[1. Set Next.js target to serverless](#1-set-nextjs-target-to-serverless)
-[Fallbacks for Pages with `getStaticPaths`](#fallbacks-for-pages-with-getstaticpaths)
31
23
-[Credits](#credits)
32
24
-[Showcase](#showcase)
@@ -47,55 +39,7 @@ This build plugin is a utility for enabling server-side rendering in Next.js on
47
39
package = "netlify-plugin-nextjs"
48
40
```
49
41
50
-
## Optional Extras
51
-
52
-
#### Preview Locally
53
-
54
-
I recommend you still use `next dev` to build and preview your application locally.
55
-
56
-
But if you want to emulate the Netlify deployment on your computer, you can also run `next-on-netlify` locally and then use `netlify-cli` to preview the result.
57
-
58
-
First, install the latest version of `netlify-cli` (you can also [look at package.json](https://github.com/netlify/next-on-netlify/blob/master/package.json) to see the version that next-on-netlify has been tested against):
59
-
60
-
```bash
61
-
npm install -g netlify-cli
62
-
```
63
-
64
-
Then, add the following `[dev]` block to your `netlify.toml`:
65
-
66
-
```toml
67
-
# netlify.toml
68
-
69
-
# [build]
70
-
# ...
71
-
72
-
[dev]
73
-
functions = "out_functions"
74
-
publish = "out_publish"
75
-
# We manually set the framework to static, otherwise Netlify automatically
Lastly, add the following lines to your `.gitignore`:
82
-
83
-
```shell
84
-
# .gitignore
85
-
86
-
# Files generated by next-on-netlify command
87
-
/out_publish/
88
-
/out_functions/
89
-
```
90
-
91
-
Now you're all set.
92
-
93
-
From now on, whenever you want to preview your application locally, just run:
94
-
95
-
1.`npm run build`: This will run `next build` to build your Next.js app and `next-on-netlify` to prepare your Next.js app for compatibility with Netlify
96
-
1.`netlify dev`: This will emulate Netlify on your computer and let you preview your app on `http://localhost:8888`.
97
-
98
-
#### Custom Netlify Redirects
42
+
## Custom Netlify Redirects
99
43
100
44
You can define custom redirects in a `_redirects` and/or in your `netlify.toml` file.
101
45
The precedence of these rules are:
@@ -106,7 +50,7 @@ The precedence of these rules are:
106
50
107
51
[Read more about Netlify redirects here](https://docs.netlify.com/routing/redirects/).
108
52
109
-
####Custom Netlify Functions
53
+
## Custom Netlify Functions
110
54
111
55
`next-on-netlify` creates one Netlify Function for each of your
112
56
SSR pages and API endpoints. It is currently not possible to create custom Netlify Functions. Let me know if you have a need for this feature and we can add it.
@@ -115,9 +59,9 @@ SSR pages and API endpoints. It is currently not possible to create custom Netli
115
59
116
60
### Fallbacks for Pages with `getStaticPaths`
117
61
118
-
[Fallback pages](https://nextjs.org/docs/basic-features/data-fetching#fallback-true) behave differently with `next-on-netlify` than they do with Next.js. On Next.js, when navigating to a path that is not defined in `getStaticPaths`, it first displays the fallback page. Next.js then generates the HTML in the background and caches it for future requests.
62
+
[Fallback pages](https://nextjs.org/docs/basic-features/data-fetching#fallback-true) behave differently with this plugin than they do with Next.js. On Next.js, when navigating to a path that is not defined in `getStaticPaths`, it first displays the fallback page. Next.js then generates the HTML in the background and caches it for future requests.
119
63
120
-
With `next-on-netlify`, when navigating to a path that is not defined in `getStaticPaths`, it server-side renders the page and sends it directly to the user. The user never sees the fallback page. The page is not cached for future requests.
64
+
With this plugin, when navigating to a path that is not defined in `getStaticPaths`, it server-side renders the page and sends it directly to the user. The user never sees the fallback page. The page is not cached for future requests.
121
65
122
66
For more on this, see: [Issue #7](https://github.com/netlify/next-on-netlify/issues/7#issuecomment-636883539)
0 commit comments