UNPKG

29.1 kBMarkdownView Raw
1## Netlify Lambda
2
3This is an optional tool that helps with building or locally developing [Netlify Functions](https://www.netlify.com/docs/functions/?utm_source=github&utm_medium=swyx-netlify-lambda&utm_campaign=devex) with a simple webpack/babel build step. For function folders, there is also a small utility to install function folder dependencies.
4
5The goal is to make it easy to write Lambda's with transpiled JS/TypeScript features and imported modules.
6
7<details>
8 <summary><b>Multiple ways to deploy functions on Netlify</b></summary>
9
10There are 3 ways to deploy functions to Netlify:
11
121. each function as a single JS or Go file, possibly bundled by a build tool like `netlify-lambda` or `tsc`
132. each function as a zip of a folder of files
143. as of [CLI v2.7](https://www.netlify.com/docs/cli/#unbundled-javascript-function-deploys?utm_source=github&utm_medium=swyx-netlify-lambda&utm_campaign=devex), a non-bundled, non-zipped, folder of files.
15
16`Netlify-Lambda` uses webpack to bundle up your functions and their dependencies for you, suiting the first approach. However, if you have native node modules (or other dependencies that don't expect to be bundled like [the Firebase SDK](https://github.com/netlify/netlify-lambda/issues/112)) then you may want to try the other approaches. In particular, try [`Netlify Dev`](https://www.netlify.com/docs/cli/?utm_source=github&utm_medium=swyx-jamstack&utm_campaign=devex#netlify-dev-beta).
17
18If this sounds confusing, support is available through [our regular channels](https://www.netlify.com/support/?utm_source=github&utm_medium=swyx-netlify-lambda&utm_campaign=devex).
19
20</details>
21
22
23### When to use Netlify Dev or `netlify-lambda` or both?
24
25<details>
26 <summary><a href="https://www.netlify.com/docs/cli/?utm_source=github&utm_medium=swyx-jamstack&utm_campaign=devex#netlify-dev-beta">Netlify Dev</a> is incrementally adoptable. <b>Use `netlify-lambda` only if you need a build step for your functions.</b> Expand this to read more on when to use either or both</summary>
27
28
29- **When to use Netlify Dev**: Part of Netlify Dev serves unbundled function folders through [zip-it-and-ship-it](https://github.com/netlify/zip-it-and-ship-it) with no build step. This is likely to be attractive to many users who previously just needed `netlify-lambda` for bundling multi-file functions or functions with node_module dependencies.
30- **When to use Netlify Lambda**: However, if you need a build step for your functions (e.g. for webpack import/export syntax, running babel transforms or typescript), you can use `netlify-lambda`, `tsc` or your own build tool to do this, just point Netlify Dev at your build output with the `functions` field in `netlify.toml`.
31- These responsibilities aren't exactly the same. Therefore **you can use Netlify Dev and Netlify Lambda together** to have BOTH a build step for functions from `netlify-lambda` and the full proxy environment from Netlify Dev. If you have a npm script in `package.json` for running `netlify-lambda serve ${functionsSourceFolder}`, Netlify Dev will [detect it](https://github.com/netlify/netlify-dev-plugin#function-builders-function-builder-detection-and-relationship-with-netlify-lambda) and run it for you. This way, **existing `netlify-lambda` users will be able to use Netlify Dev with no change to their workflow**
32
33Function Builder detection is a very new feature with only simple detection logic for now, that we aim to improve over time. If it doesn't work well for you, you can simply not use Netlify Dev for now while we work out all your bug reports. 🙏🏼
34
35**You can see how to convert a Netlify-Lambda project to Netlify Dev as well as why and how they work together in [this 48 min video here](https://www.youtube.com/watch?v=sakKOT6nkkE)**
36
37</details>
38
39## Installation
40
41**We recommend installing locally** rather than globally:
42
43```bash
44npm install netlify-lambda
45```
46
47This will ensure your build scripts don't assume a global install which is better for your CI/CD (for example with Netlify's buildbot).
48
49If you don't have a [`netlify.toml`](https://www.netlify.com/docs/netlify-toml-reference/?utm_source=github&utm_medium=swyx-netlify-lambda&utm_campaign=devex) file, you'll need one ([example](https://github.com/netlify/create-react-app-lambda/blob/master/netlify.toml)). Define the `functions` field where the functions will be built to and served from, e.g.
50
51```toml
52# example netlify.toml
53[build]
54 command = "npm run build"
55 functions = "lambda" # netlify-lambda reads this
56 publish = "build"
57```
58
59## Usage
60
61We expose three commands:
62
63```bash
64netlify-lambda build <folder>
65netlify-lambda install [folder]
66
67## legacy command - only preserved for backward compatibility
68netlify-lambda serve <folder>
69```
70
71### `netlify-lambda install`
72
73Sometimes your function folders will have dependencies unique to them, managed by a package.json local to that folder. This is a small utility function for installing those dependencies either on your local machine or as part of your build commands.
74
75By default it just runs on the functions folder specified in `netlify.toml`. Here's all you need to add to your `package.json` (see [this example](https://github.com/sw-yx/gatsby-netlify-form-example-v2/commit/f88462a4c37b5ddcdf5f394606ac14b58d6b475d#diff-b9cfc7f2cdf78a7f4b91a753d10865a2)):
76
77```js
78// package.json
79{
80 "dependencies": { // you probably don't want it in devDependencies! This is a common gotcha https://www.netlify.com/docs/build-gotchas/#devdependencies
81 "netlify-lambda": "^1.6.0"
82 },
83 "scripts": {
84 "postinstall": "netlify-lambda install"
85 }
86}
87```
88
89This is what you should do if you are just using Netlify Dev without `netlify-lambda`.
90
91If you're using `netlify-lambda serve` or `build`, however, you will want to run this install on the _source_ folder rather than the _dist_/netlify.toml functions folder, so you should run it with the same exact folder name as with those other commands:
92
93```bash
94netlify-lambda install <folderName>
95```
96
97We don't anticipate you will use this as often but it can be handy.
98
99### `netlify-lambda build`
100
101At a high level, `netlify-lambda` takes a source folder (e.g. `src/lambda`, specified in your command) and outputs it to a built folder, (e.g. `built-lambda`, specified in your `netlify.toml` file).
102
103The `build` function will run a single build of the functions in the folder.
104
105The `serve` function will start a dev server for the source folder and route requests with a `.netlify/functions/` prefix, with a default port of `9000`:
106
107```
108folder/hello.js -> http://localhost:9000/.netlify/functions/hello
109```
110
111It also watches your files and restarts the dev server on change. Note: if you add a new file you should kill and restart the process to pick up the new file.
112
113**IMPORTANT**:
114
115- You need a [`netlify.toml`](https://www.netlify.com/docs/netlify-toml-reference/?utm_source=github&utm_medium=swyx-netlify-lambda&utm_campaign=devex) file with a `functions` field.
116- Every function needs to be a top-level js/ts/mjs file. You can have subfolders inside the `netlify-lambda` folder, but those are only for supporting files to be imported by your top level function. Files that end with `.spec.*` or `.test.*` will be ignored so you can [colocate your tests](https://github.com/netlify/netlify-lambda/issues/99).
117- Function signatures follow the [AWS event handler](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html) syntax but must be named `handler`. [We use Node v8](https://www.netlify.com/blog/2018/04/03/node.js-8.10-now-available-in-netlify-functions/?utm_source=github&utm_medium=swyx-netlify-lambda&utm_campaign=devex) so `async` functions **are** supported ([beware common mistakes](https://serverless.com/blog/common-node8-mistakes-in-lambda/)!). Read [Netlify Functions docs](https://www.netlify.com/docs/functions/#javascript-lambda-functions?utm_source=github&utm_medium=swyx-netlify-lambda&utm_campaign=devex) for more info.
118- Functions [time out in 10 seconds](https://www.netlify.com/docs/functions/#custom-deployment-options) by default although extensions can be requested. We [try to replicate this locally](https://github.com/netlify/netlify-lambda/pull/116).
119
120<details>
121 <summary><b>Environment variables in build and branch context</b></summary>
122
123Read Netlify's [documentation on environment variables](https://www.netlify.com/docs/continuous-deployment/#build-environment-variables?utm_source=github&utm_medium=swyx-netlify-lambda&utm_campaign=devex).
124`netlify-lambda` should respect the env variables you supply in `netlify.toml` accordingly (except for deploy previews, which make no sense to locally emulate).
125
126However, this is a [relatively new feature](https://github.com/netlify/netlify-lambda/issues/59), so if you encounter issues, file one.
127
128If you need local-only environment variables that you don't place in `netlify.toml` for security reasons, you can configure webpack to use a `.env` file [like in this example](https://github.com/netlify/netlify-lambda/issues/118).
129
130</details>
131
132 <summary>
133 <b>Lambda function examples</b>
134 </summary>
135 If you are new to writing Lambda functions, this section may help you. Function signatures should conform to one of either two styles. Traditional callback style:
136
137 ```js
138// legacy callback style - not encouraged anymore, but you'll still see examples doing this
139exports.handler = function(event, context, callback) {
140 // your server-side functionality
141 callback(null, {
142 statusCode: 200,
143 body: JSON.stringify({
144 message: `Hello world ${Math.floor(Math.random() * 10)}`
145 })
146 });
147};
148 ```
149
150 or you can use async/await:
151
152 ```js
153// modern JS style - encouraged
154export async function handler(event, context) {
155 return {
156 statusCode: 200,
157 body: JSON.stringify({ message: `Hello world ${Math.floor(Math.random() * 10)}` })
158 };
159}
160 ```
161> :warning: The above example only works with `netlify-lambda` because [it uses ES module syntax](https://community.netlify.com/t/async-await-lambda-function-example/6976/3)! If you get `Function invocation failed: SyntaxError: Unexpected token 'export'.` errors, this is why.
162
163 For more Functions examples, check:
164
165 - https://functions-playground.netlify.com/ (introductory)
166 - https://functions.netlify.com/examples/ (our firehose of all functions examples)
167 - the blogposts at the bottom of this README
168
169 </details>
170
171### `netlify-lambda serve` (legacy command)
172
173This command is pretty much superceded by Netlify Dev. We only keep it around for legacy/backward compatibility support reasons.
174
175#### `netlify-lambda serve` (legacy command): Using with `create-react-app`, Gatsby, and other development servers
176
177<details>
178<summary><b>Why you need to proxy (for beginners)</b></summary>
179
180`react-scripts` (the underlying library for `create-react-app`) and other popular development servers often set up catchall serving for you; in other words, if you try to request a route that doesn't exist, the dev server will try to serve you `/index.html`. This is problematic when you are trying to hit a local API endpoint like `netlify-lambda` sets up for you - your browser will attempt to parse the `index.html` file as JSON. This is why you may see this error:
181
182`Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0`
183
184If this desribes your situation, then you need to proxy for local development. Read on. Don't worry it's easier than it looks.
185
186</details>
187
188#### `netlify-lambda serve` (legacy command): Proxying for local development
189
190> ⚠️IMPORTANT! PLEASE READ THIS ESPECIALLY IF YOU HAVE CORS ISSUES⚠️
191
192When your function is deployed on Netlify, it will be available at `/.netlify/functions/function-name` for any given deploy context. It is advantageous to proxy the `netlify-lambda serve` development server to the same path on your primary development server.
193
194Say you are running `webpack-serve` on port 8080 and `netlify-lambda serve` on port 9000. Mounting `localhost:9000` to `/.netlify/functions/` on your `webpack-serve` server (`localhost:8080/.netlify/functions/`) will closely replicate what the final production environment will look like during development, and will allow you to assume the same function url path in development and in production.
195
196- If you are using with `create-react-app`, see [netlify/create-react-app-lambda](https://github.com/netlify/create-react-app-lambda/blob/f0e94f1d5a42992a2b894bfeae5b8c039a177dd9/src/setupProxy.js) for an example of how to do this with `create-react-app`. [setupProxy is partially documented in the CRA docs](https://facebook.github.io/create-react-app/docs/proxying-api-requests-in-development#configuring-the-proxy-manually). You can also learn how to do this from scratch in a video: https://www.youtube.com/watch?v=3ldSM98nCHI
197- If you are using Gatsby, see [their Advanced Proxying docs](https://www.gatsbyjs.org/docs/api-proxy/#advanced-proxying). This is implemented in the [JAMstack Hackathon Starter](https://github.com/sw-yx/jamstack-hackathon-starter).
198- If you are using React-Static, check https://github.com/nozzle/react-static/issues/380.
199- If you are using Nuxt.js, see [this issue for how to proxy](https://github.com/netlify/netlify-lambda/pull/28#issuecomment-439675503).
200- If you are using Vue CLI, you may just use https://github.com/netlify/vue-cli-plugin-netlify-lambda/.
201- If you are using with Angular CLI, see the instructions below.
202
203[Example webpack config](https://github.com/imorente/netlify-functions-example/blob/master/webpack.development.config):
204
205```js
206module.exports = {
207 mode: "development",
208 devServer: {
209 proxy: {
210 "/.netlify": {
211 target: "http://localhost:9000",
212 pathRewrite: { "^/.netlify/functions": "" }
213 }
214 }
215 }
216};
217```
218
219<details>
220 <summary>
221 <b>Using with <code>Angular CLI</code></b>
222 </summary>
223
224CORS issues when trying to use netlify-lambdas locally with angular? you need to set up a proxy.
225
226Firstly make sure you are using relative paths in your app to ensure that your app will work locally and on Netlify, example below...
227
228```js
229this.http.get("/.netlify/functions/jokeTypescript");
230```
231
232Then place a `proxy.config.json` file in the root of your project, the contents should look something like...
233
234```json
235{
236 "/.netlify/functions/*": {
237 "target": "http://localhost:9000",
238 "secure": false,
239 "logLevel": "debug",
240 "changeOrigin": true
241 }
242}
243```
244
245- The `key` should match up with the location of your Transpiled `functions` as defined in your `netlify.toml`
246- The `target` should match the port that the lambdas are being served on (:9000 by default)
247
248When you run up your Angular project you need to pass in the proxy config with the flag `--proxy-config` like so...
249
250```bash
251 ng serve --proxy-config proxy.config.json
252```
253
254To make your life easier you can add these to your `scripts` in `package.json`
255
256```json
257 "scripts": {
258 "start": "ng serve --proxy-config proxy.config.json",
259 "build": "ng build --prod --aot && yarn nlb",
260 "nls": "netlify-lambda serve src_functions",
261 "nlb": "netlify-lambda build src_functions"
262 }
263```
264
265Obviously you need to run up `netlify-lambda` & `angular` at the same time.
266
267</details>
268<details>
269 <summary>
270 <b>Using with <code>Next.js</code></b>
271 </summary>
272
273Next.js [doesnt use Webpack Dev Server](https://github.com/zeit/next.js/issues/2281), so you can't modify any config in `next.config.js` to get a proxy to run. However, since the CORS proxy issue only happens in dev mode (Functions are on the same domain when deployed on Netlify) you can run Next.js through a Node server for local development:
274
275```js
276touch server.js
277yarn add -D http-proxy-middleware express
278```
279
280```js
281// server.js
282/* eslint-disable no-console */
283const express = require("express");
284const next = require("next");
285
286const devProxy = {
287 "/.netlify": {
288 target: "http://localhost:9000",
289 pathRewrite: { "^/.netlify/functions": "" }
290 }
291};
292
293const port = parseInt(process.env.PORT, 10) || 3000;
294const env = process.env.NODE_ENV;
295const dev = env !== "production";
296const app = next({
297 dir: ".", // base directory where everything is, could move to src later
298 dev
299});
300
301const handle = app.getRequestHandler();
302
303let server;
304app
305 .prepare()
306 .then(() => {
307 server = express();
308
309 // Set up the proxy.
310 if (dev && devProxy) {
311 const proxyMiddleware = require("http-proxy-middleware");
312 Object.keys(devProxy).forEach(function(context) {
313 server.use(proxyMiddleware(context, devProxy[context]));
314 });
315 }
316
317 // Default catch-all handler to allow Next.js to handle all other routes
318 server.all("*", (req, res) => handle(req, res));
319
320 server.listen(port, err => {
321 if (err) {
322 throw err;
323 }
324 console.log(`> Ready on port ${port} [${env}]`);
325 });
326 })
327 .catch(err => {
328 console.log("An error occurred, unable to start the server");
329 console.log(err);
330 });
331```
332
333run your server and netlify-lambda at the same time:
334
335```js
336// package.json
337 "scripts": {
338 "start": "cross-env NODE_ENV=dev npm-run-all --parallel start:app start:server",
339 "start:app": "PORT=3000 node server.js",
340 "start:server": "netlify-lambda serve functions"
341 },
342```
343
344and now you can ping Netlify Functions with locally emulated by `netlify-lambda`!
345
346For production deployment, you have two options:
347
348- [using `next export` to do static HTML export](https://nextjs.org/docs/#static-html-export)
349- [using the Next.js 8 `serverless` target option](https://nextjs.org/blog/next-8/#serverless-nextjs) to run your site in a function as well.
350
351Just remember to configure your `netlify.toml` to point to the `Next.js` build folder and your `netlify-lambda` functions folder accordingly.
352
353</details>
354
355## Webpack Configuration
356
357By default the webpack configuration uses `babel-loader` to load all js files. Any `.babelrc` in the directory `netlify-lambda` is run from will be respected. If no `.babelrc` is found, a [few basic settings are used](https://github.com/netlify/netlify-lambda/blob/master/lib/build.js#L11-L15a).
358
359If you need to use additional webpack modules or loaders, you can specify an additional webpack config with the `-c`/`--config` option when running either `serve` or `build`.
360
361For example, have a file with:
362
363```js
364// webpack.functions.js
365module.exports = {
366 optimization: { minimize: false }
367};
368```
369
370Then specify `netlify-lambda serve --config ./webpack.functions.js`. If using VSCode, it is likely that the `sourceMapPathOverrides` have to be adapted for breakpoints to work. Read here for more info on [how to modify the webpack config](https://github.com/netlify/netlify-lambda/issues/64#issuecomment-429625191).
371
372If you're using firebase SDK and other native modules, check [this issue](https://github.com/netlify/netlify-lambda/issues/112#issuecomment-489072330) and use this plugin:
373
374```
375//./config/webpack.functions.js
376const nodeExternals = require('webpack-node-externals');
377
378module.exports = {
379 externals: [nodeExternals()],
380};
381```
382
383The additional webpack config will be merged into the default config via [webpack-merge's](https://www.npmjs.com/package/webpack-merge) `merge.smart` method.
384
385### Babel configuration
386
387The default webpack configuration uses `babel-loader` with a [few basic settings](https://github.com/netlify/netlify-lambda/blob/master/lib/build.js#L19-L33).
388
389However, if any `.babelrc` is found in the directory `netlify-lambda` is run from, or [folders above it](https://github.com/netlify/netlify-lambda/pull/92) (useful for monorepos), it will be used instead of the default one.
390
391It is possible to disable this behaviour by passing `--babelrc false`.
392
393If you need to run different babel versions for your lambda and for your app, [check this issue](https://github.com/netlify/netlify-lambda/issues/34) to override your webpack babel-loader.
394
395### Use with TypeScript
396
397We added `.ts` and `.mjs` support recently - [check here for the PR and usage tips](https://github.com/netlify/netlify-lambda/pull/76).
398
3991. Install `@babel/preset-typescript`
400
401```bash
402npm install --save-dev @babel/preset-typescript
403```
404
405You may also want to add `typescript @types/node @types/aws-lambda`.
406
4072. Create a custom `.babelrc` file:
408
409```diff
410{
411 "presets": [
412 "@babel/preset-typescript",
413 "@babel/preset-env"
414 ],
415 "plugins": [
416 "@babel/plugin-proposal-class-properties",
417 "@babel/plugin-transform-object-assign",
418 "@babel/plugin-proposal-object-rest-spread"
419 ]
420}
421```
422
4233. (Optional) if you have `@types/aws-lambda` installed, your lambda functions can use the community typings for `Handler, Context, Callback`. See the typescript instructions in [create-react-app-lambda](https://github.com/netlify/create-react-app-lambda/blob/master/README.md#typescript) for an example.
424
425Check https://github.com/sw-yx/create-react-app-lambda-typescript for a CRA + Lambda full Typescript experience.
426
427## CLI flags/options
428
429There are additional CLI options:
430
431```bash
432-h --help
433-c --config
434-p --port
435-s --static
436-t --timeout
437-b --babelrc
438```
439
440### --config option
441
442If you need to use additional webpack modules or loaders, you can specify an additional webpack config with the `-c`/`--config` option when running either `serve` or `build`.
443
444For example, have a file with:
445
446```js
447// webpack.functions.js
448module.exports = {
449 optimization: { minimize: false }
450};
451```
452
453Then specify `netlify-lambda serve --config ./webpack.functions.js`.
454
455### --timeout option
456
457(This is for local dev/serving only) The default function timeout is 10 seconds. If you need to adjust this because you have requested extra timeout, pass a timeout number here. Thanks to [@naipath](https://github.com/netlify/netlify-lambda/pull/116) for this feature.
458
459### --port option
460
461The serving port can be changed with the `-p`/`--port` option.
462
463### --static option
464
465If you need an escape hatch and are building your lambda in some way that is incompatible with our build process, you can skip the build with the `-s` or `--static` flag. [More info here](https://github.com/netlify/netlify-lambda/pull/62).
466
467### --babelrc
468
469Defaults to `true`
470
471Use a `.babelrc` found in the directory `netlify-lambda` is run from. This can be useful when you have conflicting babel-presets, more info [here](#babel-configuration)
472
473## Netlify Identity
474
475Make sure to [read the docs](https://www.netlify.com/docs/functions/#identity-and-functions?utm_source=github&utm_medium=swyx-netlify-lambda&utm_campaign=devex) on how Netlify Functions and Netlify Identity work together. Basically you have to make your request with an `authorization` header and a `Bearer` token with your Netlify Identity JWT supplied. You can get this JWT from any of our Identity solutions from [gotrue-js](https://github.com/netlify/gotrue-js) to [netlify-identity-widget](https://github.com/netlify/netlify-identity-widget).
476
477Since for practical purposes we cannot fully emulate Netlify Identity locally, we provide [simple JWT decoding inside the `context` of your function](https://github.com/netlify/netlify-lambda/pull/57). This will give you back the `user` info you need to work with.
478
479Minor note: For the `identity` field, since we are not fully emulating Netlify Identity, we can't give you details on the Identity instance, so we give you [unambiguous strings](https://github.com/netlify/netlify-lambda/blob/master/lib/serve.js#L87) so you know not to rely on it locally: `NETLIFY_LAMBDA_LOCALLY_EMULATED_IDENTITY_URL` and `NETLIFY_LAMBDA_LOCALLY_EMULATED_IDENTITY_TOKEN`. In production, of course, Netlify Functions will give you the correct `identity.url` and `identity.token` fields. We find we dont use this info often in our functions so it is not that big of a deal in our judgment.
480
481## Debugging
482
483To debug lambdas, it can be helpful to turn off minification and enable logging. Prepend the `serve` command with [npm's package runner npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b), e.g. `npx --node-arg=--inspect netlify-lambda serve ...`.
484
4851. make sure that sourcemaps are built along the way (e.g. in the webpack configuration and the `tsconfig.json` if typescript is used)
4862. webpack's minification/uglification is turned off (see below):
487
488For example, to customize the webpack config you can have a file with:
489
490```js
491// webpack.functions.js
492module.exports = {
493 optimization: { minimize: false }
494};
495```
496
497You can see [a sample project with this setup here](https://github.com/sw-yx/throwaway-test-netlify-lambda).
498
499So you can run something like `npx --node-arg=--inspect netlify-lambda serve --config ./webpack.functions.js`. If using VSCode, it is likely that the `sourceMapPathOverrides` have to be adapted for breakpoints to work. Read here for more info on [how to modify the webpack config](https://github.com/netlify/netlify-lambda/issues/64#issuecomment-429625191).
500
501Netlify Functions [run in Node v8.10](https://www.netlify.com/blog/2018/04/03/node.js-8.10-now-available-in-netlify-functions/?utm_source=github&utm_medium=swyx-netlify-lambda&utm_campaign=devex) and you may need to run the same version to mirror the environment locally. Also make sure to check that you aren't [committing one of these common Node 8 mistakes in Lambda!](https://serverless.com/blog/common-node8-mistakes-in-lambda/)
502
503**Special warning on `node-fetch`**: `node-fetch` and webpack [currently don't work well together](https://github.com/bitinn/node-fetch/issues/450). You will have to use the default export in your code:
504
505```js
506const fetch = require("node-fetch").default; // not require('node-fetch')
507```
508
509Don't forget to search our issues in case someone has run into a similar problem you have!
510
511## Example functions and Tutorials
512
513You can do a great deal with lambda functions! Here are some examples for inspiration:
514
515- Basic Netlify Functions tutorial: https://flaviocopes.com/netlify-functions/
516- Netlify's list of Function examples: https://functions-playground.netlify.com/ ([Even more in the README](https://github.com/netlify/functions) as well as our full list https://functions.netlify.com/examples/)
517- Slack Notifications: https://css-tricks.com/forms-auth-and-serverless-functions-on-gatsby-and-netlify/#article-header-id-9
518- URL Shortener: https://www.netlify.com/blog/2018/03/19/create-your-own-url-shortener-with-netlifys-forms-and-functions/
519- Gatsby + Netlify Identity + Functions: [Turning the Static Dynamic: Gatsby + Netlify Functions + Netlify Identity](https://www.gatsbyjs.org/blog/2018-12-17-turning-the-static-dynamic/)
520- Raymond Camden's [Adding Serverless Functions to Your Netlify Static Site](https://www.raymondcamden.com/2019/01/08/adding-serverless-functions-to-your-netlify-static-site)
521- Travis Horn's [Netlify Lambda Functions from Scratch](https://travishorn.com/netlify-lambda-functions-from-scratch-1186f61c659e)
522- [JAMstack with Divya Sasidharan & Phil Hawksworth | Devchat.tv](https://devchat.tv/js-jabber/jsj-347-jamstack-with-divya-sasidharan-phil-hawksworth/) - Great discussion on the problems that Netlify Functions solve
523- [Netlify function error reporting with Sentry](https://httptoolkit.tech/blog/netlify-function-error-reporting-with-sentry/) - automatic error reporting for your Netlify functions, so you know any time they fail.
524- React + Stripe + Netlify Functions: [Build and deploy a serverless eCommerce project](https://mitchgavan.com/react-serverless-shop/)
525- [**Submit your blogpost here!**](https://github.com/netlify/netlify-lambda/issues/new)
526
527These libraries pair very well for extending your functions capability:
528
529- Middleware: https://github.com/middyjs/middy
530- GraphQL: https://www.npmjs.com/package/apollo-server-lambda
531- [Any others to suggest?](https://github.com/netlify/netlify-lambda/issues/new)
532
533## Other community approaches
534
535If you wish to serve the full website from lambda, [check this issue](https://github.com/netlify/netlify-lambda/issues/36).
536
537If you wish to run this server for testing, [check this issue](https://github.com/netlify/netlify-lambda/issues/49).
538
539If you wish to emulate more Netlify functionality locally, check this repo: https://github.com/8eecf0d2/netlify-local. We are considering merging the projects [here](https://github.com/netlify/netlify-lambda/issues/75).
540
541All of the above are community maintained and not officially supported by Netlify.
542
543## Changelog
544
545- v1.0: https://twitter.com/Netlify/status/1050399820484087815 Webpack 4 and Babel 7
546- v1.1: https://twitter.com/swyx/status/1069544181259849729 Typescript support
547- v1.2: https://twitter.com/swyx/status/1083446733374337024 Identity emulation (& others)
548- v1.3: https://github.com/netlify/netlify-lambda/releases/tag/v1.3.0
549- v1.4: New timeout feature https://github.com/netlify/netlify-lambda/pull/116
550- v1.5: Catch raw requests - a very common error for first time users pinging `localhost:9000` instead of `localhost:9000/.netlify/functions/myfunction` https://github.com/netlify/netlify-lambda/commit/bfebc0921a45d4f730b910b680e40e04928f7c29#diff-3288939317efd62bfc509440d662cacaR191
551- v1.6: New `install` command https://mobile.twitter.com/swyx/status/1162038490298818562
552
553## License
554
555[MIT](LICENSE)