@sveltejs/adapter-netlify 1.0.0-next.83 → 1.0.0-next.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -50,6 +50,20 @@ New projects will use Node 16 by default. However, if you're upgrading a project
50
50
 
51
51
  SvelteKit supports the beta release of [Netlify Edge Functions](https://docs.netlify.com/netlify-labs/experimental-features/edge-functions/). If you pass the option `edge: true` to the `adapter` function, server-side rendering will happen in a Deno-based edge function that's deployed close to the site visitor. If set to `false` (the default), the site will deploy to standard Node-based Netlify Functions.
52
52
 
53
+ ```js
54
+ import adapter from '@sveltejs/adapter-netlify';
55
+
56
+ export default {
57
+ kit: {
58
+ adapter: adapter({
59
+ // will create a Netlify Edge Function using Deno-based
60
+ // rather than using standard Node-based functions
61
+ edge: true
62
+ })
63
+ }
64
+ };
65
+ ```
66
+
53
67
  ## Netlify alternatives to SvelteKit functionality
54
68
 
55
69
  You may build your app using functionality provided directly by SvelteKit without relying on any Netlify functionality. Using the SvelteKit versions of these features will allow them to be used in dev mode, tested with integration tests, and to work with other adapters should you ever decide to switch away from Netlify. However, in some scenarios you may find it beneficial to use the Netlify versions of these features. One example would be if you're migrating an app that's already hosted on Netlify to SvelteKit.
@@ -69,7 +83,15 @@ During compilation, redirect rules are automatically appended to your `_redirect
69
83
 
70
84
  ### Using Netlify Functions
71
85
 
72
- With this adapter, SvelteKit endpoints are hosted as [Netlify Functions](https://docs.netlify.com/functions/overview/). Netlify function handlers have additional context, including [Netlify Identity](https://docs.netlify.com/visitor-access/identity/) information. You can access this context via the `event.platform.context` field inside your hooks and endpoints.
86
+ With this adapter, SvelteKit endpoints are hosted as [Netlify Functions](https://docs.netlify.com/functions/overview/). Netlify function handlers have additional context, including [Netlify Identity](https://docs.netlify.com/visitor-access/identity/) information. You can access this context via the `event.platform.context` field inside your hooks and `+page.server` or `+layout.server` endpoints. These are [serverless functions](https://docs.netlify.com/functions/overview/) when the `edge` property is `false` in the adapter config or [edge functions](https://docs.netlify.com/edge-functions/overview/#app) when it is `true`.
87
+
88
+ ```js
89
+ // +page.server.js
90
+ export const load = async (event) => {
91
+ const context = event.platform.context;
92
+ console.log(context); // shows up in your functions log in the Netlify app
93
+ };
94
+ ```
73
95
 
74
96
  Additionally, you can add your own Netlify functions by creating a directory for them and adding the configuration to your `netlify.toml` file. For example:
75
97
 
@@ -11,12 +11,12 @@ import 'stream/web';
11
11
  import 'worker_threads';
12
12
  import 'perf_hooks';
13
13
  import 'util/types';
14
+ import 'url';
14
15
  import 'string_decoder';
15
16
  import 'events';
16
17
  import 'tls';
17
18
  import 'async_hooks';
18
19
  import 'console';
19
- import 'url';
20
20
  import 'zlib';
21
21
  import 'crypto';
22
22