This repository was archived by the owner on May 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
feat: enhance README #155
Merged
Merged
feat: enhance README #155
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,8 @@ The plugin can be found on [npm here](https://www.npmjs.com/package/@netlify/plu | |
- [Setup](#setup) | ||
- [1. Set Next.js target to serverless](#1-set-nextjs-target-to-serverless) | ||
- [2. Add postbuild hook](#2-add-postbuild-hook) | ||
- [3. Configure Netlify](#3-configure-netlify) | ||
- [3. Configure for Netlify](#3-configure-for-netlify) | ||
- [(Optional) Configure private git submodules](#optional-configure-private-git-submodules) | ||
- [Demo](#demo) | ||
- [Optional Extras](#optional-extras) | ||
- [Preview Locally](#preview-locally) | ||
|
@@ -63,7 +64,7 @@ npm install --save next-on-netlify | |
|
||
## Setup | ||
|
||
#### 1. Set Next.js target to serverless | ||
### 1. Set Next.js target to serverless | ||
|
||
We must build our Next.js app as a serverless app. You can read more about serverless Next.js [here](https://nextjs.org/docs/api-reference/next.config.js/build-target#serverless-target). | ||
|
||
|
@@ -90,7 +91,7 @@ module.exports = { | |
}; | ||
``` | ||
|
||
#### 2. Add postbuild hook | ||
### 2. Add postbuild hook | ||
|
||
The next-on-netlify package adds the `next-on-netlify` command. When we run this command, some magic happens to prepare our Next.js app for hosting on Netlify\*. | ||
|
||
|
@@ -110,7 +111,7 @@ We want the next-on-netlify command to run after we build our Next.js applicatio | |
|
||
\*If you're curious about the "magic", check out the well-documented [`next-on-netlify.js` file](https://github.com/netlify/next-on-netlify/blob/master/next-on-netlify.js). | ||
|
||
#### 3. Configure Netlify | ||
### 3. Configure for Netlify | ||
|
||
We're almost done! We just have to tell Netlify how to build our Next.js app, where the functions folder is located, and which folder to upload to its CDN. We do that with a `netlify.toml` file and the following instructions: | ||
|
||
|
@@ -121,7 +122,27 @@ We're almost done! We just have to tell Netlify how to build our Next.js app, wh | |
publish = "out_publish" | ||
``` | ||
|
||
Note: `out_functions` and `out_publish` are hard-coded into next-on-netlify. These are not configurable at the moment. | ||
Note: `out_functions` and `out_publish` are hard-coded into next-on-netlify. | ||
These are not configurable at the moment. | ||
|
||
#### (Optional) Configure private git submodules | ||
If your project contains private submodules, in order to deploy it, you will | ||
need to: | ||
|
||
1. [Generate a Deploy | ||
Key](https://docs.netlify.com/configure-builds/repo-permissions-linking/#deploy-keys) | ||
in Netlify and [add it to the relevant | ||
submodules](https://docs.github.com/en/developers/overview/managing-deploy-keys#setup-2) | ||
so that they can be cloned during the deploy process. | ||
|
||
2. Ensure the submodule remotes are set to SSH format (i.e. | ||
`[email protected]:owner/project.git`, not `https://...`). Inside the submodule | ||
directory, the git remote can be updated with: | ||
|
||
```bash | ||
# git remote set-url [remote] [url] | ||
git remote set-url origin [email protected]:owner/project.git | ||
``` | ||
|
||
We're done. Let's deploy 🚀🚀🚀 | ||
|
||
|
@@ -132,7 +153,7 @@ We're done. Let's deploy 🚀🚀🚀 | |
|
||
## Optional Extras | ||
|
||
#### Preview Locally | ||
### Preview Locally | ||
|
||
I recommend you still use `next dev` to build and preview your application locally. | ||
|
||
|
@@ -184,7 +205,7 @@ Preview Mode is not yet available locally, running `netlify dev`, for static pag | |
|
||
For now, Preview Mode *is* supported in production for all Next.js page types. | ||
|
||
#### Custom Netlify Redirects | ||
### Custom Netlify Redirects | ||
|
||
You can define custom redirects in a `_redirects` and/or in your `netlify.toml` file. | ||
The precedence of these rules are: | ||
|
@@ -196,12 +217,12 @@ Currently, there is no support for redirects set in your `netlify.toml` file. | |
|
||
[Read more about Netlify redirects here](https://docs.netlify.com/routing/redirects/). | ||
|
||
#### Custom Netlify Functions | ||
### Custom Netlify Functions | ||
|
||
`next-on-netlify` creates one Netlify Function for each of your | ||
SSR pages and API endpoints. It is currently not possible to create custom Netlify Functions. This feature is on our list to do. | ||
|
||
#### Using Netlify Identity | ||
### Using Netlify Identity | ||
|
||
You can use [Netlify Identity](https://docs.netlify.com/visitor-access/identity/) with `next-on-netlify`. For all pages with server-side rendering (getInitialProps*, getServerSideProps, and API routes), you can access the [clientContext object](https://docs.netlify.com/functions/functions-and-identity/#access-identity-info-via-clientcontext) via the `req` parameter. | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
per your comment on the issue about this being "out-of-the-box" on vercel.. is this supported on vercel? only a few months ago this was commented: https://github.com/vercel/vercel/discussions/4566#discussioncomment-125253
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also: https://vercel.com/docs/build-step#git-submodules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very interesting - all I know is that this project deployed to Vercel w/o issue.
Wonder if they didn't adjust the default permissions for the GH access key so that it would have access to private repos by default, can't think otherwise how it didn't fail.