Merlin -they-them-
Merlin -they-them-

Reputation: 2960

Where should Meteor defaults be set?

I'd like to use Session.setDefault to set some default values for my Meteor app.

I had thought that based on the load order of Meteor files in which the top level lib folder is loaded first, the best place for this code would be lib/defaults.js file. However, when I run my code, I get a Session is not defined error

Where is the best place to put this code such that it will work on server and client?

Upvotes: 1

Views: 60

Answers (1)

SylvainB
SylvainB

Reputation: 4820

In Meteor, Session is only available on the client. Therefore, you should set your defaults in your client folder, usually in a Meteor.startup() hook.

If you need to set some common defaults to the client and server side, you can either set values on the server side and retrieve them from the client when needed using method calls (non-reactive) or use a Collection and subscribe to it! (reactive)

Upvotes: 2

Related Questions