Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs for Serverless target #6070

Merged
merged 13 commits into from
Jan 17, 2019

Conversation

timneutkens
Copy link
Member

I need feedback on if this is clear enough for users.


Examples of automatically created Serverless deployments:

- [Now v2 with `@now/next` builder](https://github.com/zeit/now-examples/tree/master/nextjs)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will have to be replaced by the guide @timothyis is writing

packages/next/README.md Outdated Show resolved Hide resolved
packages/next/README.md Outdated Show resolved Hide resolved
timothyis and others added 2 commits January 16, 2019 16:50
Co-Authored-By: timneutkens <tim@timneutkens.nl>
Co-Authored-By: timneutkens <tim@timneutkens.nl>
@lfades
Copy link
Member

lfades commented Jan 16, 2019

LOTM, it's very clear, only lacking more examples for new users, this opens the door to add micro-serverless, [koa/express]-serverless to the examples folder.

packages/next/README.md Outdated Show resolved Hide resolved
@timneutkens
Copy link
Member Author

timneutkens commented Jan 16, 2019

@lfades yep, totally, however, micro/koa/express-serverless are massive overkill for the Next.js serverless target, as all it needs is req and res from Node.js to render out a page.

The examples that I'd like to see are: AWS lambda, Google Cloud Functions, Azure and maybe Serverless framework

@timneutkens
Copy link
Member Author

timneutkens commented Jan 16, 2019

For AWS Lambda using https://github.com/awslabs/aws-serverless-express would be enough:

const awsServerlessExpress = require('aws-serverless-express')
const page = require('./.next/serverless/about.js')
const server = awsServerlessExpress.createServer((req, res) => page.render(req, res))

exports.handler = (event, context) => {
  awsServerlessExpress.proxy(server, event, context)
}

Note that I checked the source and it has nothing to do with express, it's a compat layer between event from AWS Lambda and http.Server

packages/next/README.md Show resolved Hide resolved
packages/next/README.md Outdated Show resolved Hide resolved
timneutkens and others added 8 commits January 17, 2019 15:55
…cel#6056)

Fixes vercel/now-builders#168

For some reason with a certain mix of deps `...` is not supported in webpack's parsing.
By default it is supported as all our tests passed before and we have deployed Next.js apps on v2 already.
Introduces full support for Babel 7 including JSX Fragments shorthand. 
Switched to visiting the `Program` path and then start a traversal manually to solve conflicts with other Babel plugins.
@timneutkens timneutkens merged commit c46cd3c into vercel:canary Jan 17, 2019
@timneutkens timneutkens deleted the add/serverless-docs branch January 17, 2019 15:18
JeromeFitz added a commit to JeromeFitz/next.js that referenced this pull request Jan 17, 2019
Adds a Bullet Point under "Production deployment"
 for the Table of Contens / Link Section.

Wanted to add this as a comment in vercel#6070.

Great work as always!
timneutkens pushed a commit that referenced this pull request Jan 17, 2019
Adds a Bullet Point under "Production deployment"
 for the Table of Contens / Link Section.

Wanted to add this as a comment in #6070.

Great work as always!
@timneutkens timneutkens mentioned this pull request Jan 21, 2019
8 tasks
@romainquellec
Copy link
Contributor

Someone is brave enough to make these examples ?

@timneutkens
Copy link
Member Author

Feel free to contribute @romainquellec

@lfades
Copy link
Member

lfades commented Jan 24, 2019

I would love to do the examples, @romainquellec are you working on them ? - I feel it like a good opportunity to learn more about serverless

@timneutkens
Copy link
Member Author

@lfades feel free to contribute!

@chirag04
Copy link

chirag04 commented Jan 25, 2019

I wish there was a section about debugging and dev workflows in the doc. Since all the code is minified the serverless build directory, it's really impossible to debug what's going on. thoughts? Also not sure if we can do hot reloading/re-building the target when code changes.

@kamleshchandnani
Copy link

For AWS Lambda using awslabs/aws-serverless-express would be enough:

const awsServerlessExpress = require('aws-serverless-express')
const page = require('./.next/serverless/about.js')
const server = awsServerlessExpress.createServer((req, res) => page.render(req, res))

exports.handler = (event, context) => {
  awsServerlessExpress.proxy(server, event, context)
}

Note that I checked the source and it has nothing to do with express, it's a compat layer between event from AWS Lambda and http.Server

But what if I want to add express as a middleware so that I can use multiple middlewares compression, helmet etc. for my app

@fbn4sc
Copy link

fbn4sc commented Mar 20, 2019

For AWS Lambda using awslabs/aws-serverless-express would be enough:

const awsServerlessExpress = require('aws-serverless-express')
const page = require('./.next/serverless/about.js')
const server = awsServerlessExpress.createServer((req, res) => page.render(req, res))

exports.handler = (event, context) => {
  awsServerlessExpress.proxy(server, event, context)
}

Note that I checked the source and it has nothing to do with express, it's a compat layer between event from AWS Lambda and http.Server

But what if I want to add express as a middleware so that I can use multiple middlewares compression, helmet etc. for my app

Were you able to find an answer? I'm facing the same problem right now.

@lock lock bot locked as resolved and limited conversation to collaborators Mar 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet